You are here

function multiple_selects_widget_validate in Multiple Selects 7

Form element validation handler for options element.

1 string reference to 'multiple_selects_widget_validate'
multiple_selects_field_widget_form in ./multiple_selects.module
Implements hook_field_widget_form().

File

./multiple_selects.module, line 99

Code

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