1 views_handler_filter.inc views_handler_filter::exposed_form(&$form, &$form_state)

Render our chunk of the exposed filter form when selecting

You can override this if it doesn't do what you expect.

Overrides views_handler::exposed_form

File

core/modules/views/handlers/views_handler_filter.inc, line 762
@todo.

Class

views_handler_filter
Base class for filters.

Code

function exposed_form(&$form, &$form_state) {
  if (empty($this->options['exposed'])) {
    return;
  }

  // Build the exposed form, when its based on an operator.
  if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
    $operator = $this->options['expose']['operator_id'];
    $this->operator_form($form, $form_state);
    $form[$operator] = $form['operator'];

    if (isset($form[$operator]['#title'])) {
      unset($form[$operator]['#title']);
    }

    $this->exposed_translate($form[$operator], 'operator');

    unset($form['operator']);
  }

  // Build the form and set the value based on the identifier.
  if (!empty($this->options['expose']['identifier'])) {
    $value = $this->options['expose']['identifier'];
    $this->value_form($form, $form_state);
    $form[$value] = $form['value'];

    if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') {
      unset($form[$value]['#title']);
    }

    $this->exposed_translate($form[$value], 'value');

    if (!empty($form['#type']) && ($form['#type'] == 'checkboxes' || ($form['#type'] == 'select' && !empty($form['#multiple'])))) {
      unset($form[$value]['#default_value']);
    }

    if (!empty($form['#type']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
      $form[$value]['#default_value'] = 'All';
    }

    if ($value != 'value') {
      unset($form['value']);
    }
  }
}