You are here

function options_field_widget_validate in Drupal 7

Form element validation handler for options element.

1 string reference to 'options_field_widget_validate'
options_field_widget_form in modules/field/modules/options/options.module
Implements hook_field_widget_form().

File

modules/field/modules/options/options.module, line 171
Defines selection, check box and radio button widgets for text and numeric fields.

Code

function options_field_widget_validate($element, &$form_state) {
  if ($element['#required'] && $element['#value'] == '_none') {
    form_error($element, t('!name field is required.', array(
      '!name' => $element['#title'],
    )));
  }

  // Transpose selections from field => delta to delta => field, turning
  // multiple selected options into multiple parent elements.
  $items = _options_form_to_storage($element);
  form_set_value($element, $items, $form_state);
}