Skip to content

Instantly share code, notes, and snippets.

@graceman9
Created August 8, 2014 07:24
Show Gist options
  • Save graceman9/fb9110ea00e6dc572c30 to your computer and use it in GitHub Desktop.
Save graceman9/fb9110ea00e6dc572c30 to your computer and use it in GitHub Desktop.
Drupal 7: create node_types select options, form api
<?php
// node_types select options
$types = node_type_get_types();
foreach($types as $node_type) {
$options[$node_type->type] = $node_type->name;
}
$form['onpay']['onpay_node_types'] = array(
'#type' => 'select',
'#title' => t('Node types'),
'#options' => $options,
'#multiple' => TRUE,
'#default_value' => variable_get('onpay_node_types', array());
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment