public function date_views_filter_handler_simple::value_form in Date 7.3
Same name and namespace in other branches
- 8 date_views/includes/date_views_filter_handler_simple.inc \date_views_filter_handler_simple::value_form()
- 7.2 date_views/includes/date_views_filter_handler_simple.inc \date_views_filter_handler_simple::value_form()
Add a type selector to the value form.
Overrides views_handler_filter_date::value_form
File
- date_views/
includes/ date_views_filter_handler_simple.inc, line 332 - A standard Views filter for a single date field.
Class
- date_views_filter_handler_simple
- A standard Views filter for a single date field.
Code
public 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(drupal_random_bytes(16));
$form['value']['#type'] = 'container';
if (module_exists('ctools')) {
$form['value']['#pre_render'] = array(
'ctools_dependent_pre_render',
);
}
// 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-' . drupal_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(
'date_views_select_validate',
);
}
}