You are here

function boolean_field_widget_validate in Boolean Field 7

Form element validation handler for boolean field element.

1 string reference to 'boolean_field_widget_validate'
boolean_field_widget_form in ./boolean.module
Implements hook_field_widget_form().

File

./boolean.module, line 386
Defines boolean field type.

Code

function boolean_field_widget_validate($element, &$form_state, $form) {
  $value = $element['#value'];

  // Transform '0 / 1' into the 'on / off / not set' values.
  if (!$element['#is_set'] && $value === 0) {
    $value = $element['#no_value'];
  }
  else {
    $value = $value ? $element['#on_value'] : $element['#off_value'];
  }
  form_set_value($element, $value, $form_state);
}