You are here

function units_default_form_validate in Units of Measurement 7.2

Same name and namespace in other branches
  1. 7 units_default/units_default.pages.inc \units_default_form_validate()

Validate handler for 'units_default_form' form.

Manipulate submitted values in order to clean it up from unchecked checkboxes.

1 string reference to 'units_default_form_validate'
units_default_form in units_default/units_default.pages.inc
Form to manage default units and measures.

File

units_default/units_default.pages.inc, line 73
Page menu callbacks of Units default module.

Code

function units_default_form_validate($form, &$form_state) {
  $value = $form_state['values']['units_default_enabled'];
  foreach ($value as $measure => $sub_value) {
    if (!$sub_value['measure']) {
      unset($value[$measure]);
    }
    else {
      foreach ($sub_value['units'] as $unit => $sub_sub_value) {
        if (!$sub_sub_value) {
          unset($value[$measure]['units'][$unit]);
        }
      }
    }
  }
  form_set_value($form['units_default_enabled'], $value, $form_state);
}