You are here

function options_element_field_instance_settings_validate in Options Element 7

Form #validate callback for field_ui_field_edit_form().

1 string reference to 'options_element_field_instance_settings_validate'
options_element_form_field_ui_field_edit_form_alter in ./options_element.module
Implements hook_form_FORM_ID_alter().

File

./options_element.module, line 255
Defines an "options" form element type for entering select list options.

Code

function options_element_field_instance_settings_validate($form, &$form_state) {
  $field = $form['#field'];
  if (!form_get_errors()) {

    // Set default values.
    $default_field_value_key = $form['instance']['default_value_widget'][$field['field_name']][LANGUAGE_NONE]['#value_key'];

    // Create transposed array for field storage.
    $default_values = options_array_transpose(array(
      $default_field_value_key => (array) $form['field']['settings']['allowed_values']['#value']['default_value'],
    ));
    form_set_value($form['instance']['default_value_widget'][$field['field_name']][LANGUAGE_NONE], $default_values, $form_state);
  }
}