function date_views_filter_handler_simple::value_form in Date 8
Same name and namespace in other branches
- 7.3 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 the selectors to the value form using the date handler.
File
- date_views/
includes/ date_views_filter_handler_simple.inc, line 238 - A standard Views filter for a single date field, using Date API form selectors and sql handling.
Class
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;
// 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',
);
}
}