I've made a drop-down list type Field and have exported it as part of a Feature. However, whilst every other facet of the Field (Name, Help text, etc) is successfully exported the actual Allowed Values is not.

Does anyone know how I would include this in my Feature?


Turns out this is a bug(?) in Drupal 7.

The Dropdown list field's values are not saved in Features on a per-instance basis.

This can be fixed by using hook_field_widget_form_alter in the Feature's .module file, eg:

 * Implements hook_field_widget_form_alter().
function my_colors_field_widget_form_alter(&$element, &$form_state, $context) {

  if ($form_state['build_info']['form_id'] == 'my_colors_node_form' &&
    $context['field']['field_name'] == 'field_dropdown_text_single' &&
    $element['#entity_type'] == 'node') {
    $form_field_wrapper = entity_metadata_wrapper('node', $element['#entity']);
    $default_field = $form_field_wrapper->field_dropdown_text_single->value();
    $element['#default_value'] = !empty($default_field) ? $default_field : '';
    $element['#options'] = [
    'Red' => 'Red',
    'Blue' => 'Blue',
    'Green' => 'Green',


...drupal is so great...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.