You are here

function hook_date_combo_pre_validate_alter in Date 8

Same name and namespace in other branches
  1. 7.3 date.api.php \hook_date_combo_pre_validate_alter()
  2. 7.2 date.api.php \hook_date_combo_pre_validate_alter()

Alter the date_combo element before the rest of the validation is run.

Parameters

array $element: The $element array.

array $form_state: A keyed array containing the current state of the form.

array $context: An associative array containing the following keys:

  • field: The $field array.
  • instance: The $instance array.
  • item: The $item array.

See also

date_combo_element_process()

2 functions implement hook_date_combo_pre_validate_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

date_all_day_date_combo_pre_validate_alter in date_all_day/date_all_day.module
Implements hook_date_combo_pre_validate_alter().
date_repeat_field_date_combo_pre_validate_alter in date_repeat_field/date_repeat_field.module
Implements hook_date_combo_pre_validate_alter().
1 invocation of hook_date_combo_pre_validate_alter()
date_combo_validate in ./date_elements.inc
Validate and update a combo element. Don't try this if there were errors before reaching this point.

File

./date.api.php, line 162
Hooks provided by the Date module.

Code

function hook_date_combo_pre_validate_alter(&$element, &$form_state, $context) {
  if (!empty($context['item']['all_day'])) {
    $field = $context['field'];

    // If we have an all day flag on this date and the time is empty, change the
    // format to match the input value so we don't get validation errors.
    $element['#date_is_all_day'] = TRUE;
    $element['value']['#date_date_format'] = date_part_format('date', $element['value']['#date_date_format']);
    if (!empty($field['settings']['todate'])) {
      $element['value2']['#date_date_format'] = date_part_format('date', $element['value2']['#date_date_format']);
    }
  }
}