1 date_views_filter_handler_simple.inc date_views_filter_handler_simple::value_form(&$form, &$form_state)

Add the selectors to the value form using the date handler.

Overrides views_handler_filter_date::value_form

File

core/modules/date/views/date_views_filter_handler_simple.inc, line 283
A standard Views filter for a single date field, using Date API form selectors and sql handling.

Class

date_views_filter_handler_simple
@file A standard Views filter for a single date field, using Date API form selectors and sql handling.

Code

function value_form(&$form, &$form_state) {
  // We use different values than the parent form, so we must
  // construct our own form element.
  $form['value'] = array();
  $form['value']['#tree'] = TRUE;
  $form['value']['#id'] = 'date_views_exposed_filter-' . bin2hex(backdrop_random_bytes(16));

  // Below section copied from views_handler_filter_numeric.inc.
  $which = 'all';
  $source = '';
  if (!empty($form['operator'])) {
    $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : '#edit-options-operator';
  }

  $identifier = $this->options['expose']['identifier'];
  if (!empty($form_state['exposed'])) {

    if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
      // exposed and locked.
      $which = in_array($this->operator, $this->operator_values(2)) ? 'minmax' : 'value';
    }
    else {
      $source = '#edit-' . backdrop_html_id($this->options['expose']['operator_id']);
    }
  }

  if ($which == 'all' || $which == 'value') {
    $form['value'] += $this->date_parts_form($form_state, 'value', $source, $which, $this->operator_values(1), $identifier, 'default_date');
  }

  if ($which == 'all' || $which == 'minmax') {
    $form['value'] += $this->date_parts_form($form_state, 'min', $source, $which, $this->operator_values(2), $identifier, 'default_date');
    $form['value'] += $this->date_parts_form($form_state, 'max', $source, $which, $this->operator_values(2), $identifier, 'default_to_date');
  }

  // Add some extra validation for the select widget to be sure that
  // the user inputs all parts of the date.
  if ($this->options['form_type'] == 'date_select') {
    $form['value']['#element_validate'] = array(array($this, 'date_select_validate'));
  }

}