public function SearchApiViewsHandlerFilterDate::value_form in Search API 7
Provide a form for setting the filter value.
Overrides SearchApiViewsHandlerFilterNumeric::value_form
File
- contrib/
search_api_views/ includes/ handler_filter_date.inc, line 88 - Contains SearchApiViewsHandlerFilterDate.
Class
- SearchApiViewsHandlerFilterDate
- Views filter handler base class for handling date fields.
Code
public function value_form(&$form, &$form_state) {
parent::value_form($form, $form_state);
$is_date_popup = $this->options['widget_type'] == 'date_popup' && module_exists('date_popup');
// If the operator is between
if ($this->operator == 'between') {
if ($is_date_popup) {
$form['value']['min']['#type'] = 'date_popup';
$form['value']['min']['#date_format'] = $this->options['date_popup_format'];
$form['value']['min']['#date_year_range'] = $this->options['year_range'];
$form['value']['max']['#type'] = 'date_popup';
$form['value']['max']['#date_format'] = $this->options['date_popup_format'];
$form['value']['max']['#date_year_range'] = $this->options['year_range'];
}
}
elseif ($is_date_popup) {
// Add an "id" for the "value" field, since it is expected in
// date_views_form_views_exposed_form_alter().
// @see date_views_filter_handler_simple::value_form()
$form['value']['#id'] = 'date_views_exposed_filter-' . bin2hex(drupal_random_bytes(16));
$form['value']['#type'] = 'date_popup';
$form['value']['#date_format'] = $this->options['date_popup_format'];
$form['value']['#date_year_range'] = $this->options['year_range'];
unset($form['value']['#description']);
}
elseif (empty($form_state['exposed'])) {
$form['value']['#description'] = t('A date in any format understood by <a href="@doc-link">PHP</a>. For example, "@date1" or "@date2".', array(
'@doc-link' => 'http://php.net/manual/en/function.strtotime.php',
'@date1' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s'),
'@date2' => 'now + 1 day',
));
}
}