protected function ViewsSearchApiYearFilterDate::valueForm in Views year filter 8
Adds a form for entering the value or values for the filter.
Overridden to remove fields that won't be used (but aren't hidden either because of a small bug/glitch in the original form code – see #2637674).
Parameters
array $form: The form array, passed by reference.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides SearchApiFilterTrait::valueForm
See also
\Drupal\views\Plugin\views\filter\FilterPluginBase::valueForm()
File
- src/
Plugin/ views/ filter/ ViewsSearchApiYearFilterDate.php, line 26
Class
- ViewsSearchApiYearFilterDate
- Date/time views filter.
Namespace
Drupal\views_year_filter\Plugin\views\filterCode
protected function valueForm(&$form, FormStateInterface $form_state) {
parent::valueForm($form, $form_state);
if (!$form_state
->get('exposed')) {
$form['value']['type'] = [
'#type' => 'radios',
'#title' => $this
->t('Value type'),
'#options' => [
'date' => $this
->t('A date in any machine readable format. CCYY-MM-DD HH:MM:SS is preferred.'),
'date_year' => $this
->t('A date in yyyy format.'),
'offset' => $this
->t('An offset from the current time such as "@example1" or "@example2"', [
'@example1' => '+1 day',
'@example2' => '-2 hours -30 minutes',
]),
],
'#default_value' => isset($this->value['type']) ? $this->value['type'] : 'date',
];
// Add js to handle year filter state.
$form['#attached']['library'][] = 'views_year_filter/year_filter';
}
}