Last active
August 29, 2015 14:05
-
-
Save graceman9/e906e958858a465009b1 to your computer and use it in GitHub Desktop.
Drupal 7: form api options from specific entity (node_type)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$entity_type = 'node'; | |
$bundle_name = 'gift'; | |
$fields = field_info_instances($entity_type, $bundle_name); | |
$options = array(); | |
foreach ($fields as $name => $field) { | |
$options[$name] = $field['label']; | |
} | |
$form['field_price'] = array( | |
'#type' => 'select', | |
'#title' => t('Price'), | |
'#options' => $options, | |
'#default_value' => variable_get('field_price', ''), | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment