You are here

function merci_hours_quickset_options_setting_validate in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

1 string reference to 'merci_hours_quickset_options_setting_validate'
merci_hours_quickset_date_field_instance_settings_form_alter in merci_hours/merci_hours_quickset.module
Implements hook_date_field_instance_settings_form_alter().

File

merci_hours/merci_hours_quickset.module, line 71

Code

function merci_hours_quickset_options_setting_validate($element, &$form_state) {
  $values = list_extract_allowed_values($element['#value'], 'merci_quickset_options', false);
  if (!is_array($values)) {
    form_error($element, t('Allowed values list: invalid input.'));
  }
  else {

    // Check that keys are valid for the field type.
    foreach ($values as $key => $value) {
      if (strtotime($key) === false) {
        form_error($element, t('Quickset options: %value is not a relative format.', array(
          '%value' => $key,
        )));
      }
    }
    form_set_value($element, $values, $form_state);
  }
}