You are here

public function DateRecurFilter::buildOptionsForm in Recurring Dates Field 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/views/filter/DateRecurFilter.php \Drupal\date_recur\Plugin\views\filter\DateRecurFilter::buildOptionsForm()
  2. 3.0.x src/Plugin/views/filter/DateRecurFilter.php \Drupal\date_recur\Plugin\views\filter\DateRecurFilter::buildOptionsForm()
  3. 3.1.x src/Plugin/views/filter/DateRecurFilter.php \Drupal\date_recur\Plugin\views\filter\DateRecurFilter::buildOptionsForm()

Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.

Overrides FilterPluginBase::buildOptionsForm

File

src/Plugin/views/filter/DateRecurFilter.php, line 183

Class

DateRecurFilter
Date range/occurrence filter.

Namespace

Drupal\date_recur\Plugin\views\filter

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) : void {
  parent::buildOptionsForm($form, $form_state);
  $form['value_granularity'] = [
    '#title' => $this
      ->t('Granularity'),
    '#description' => $this
      ->t('Select the level of granularity of occurrences.'),
    '#type' => 'select',
    '#options' => [
      'year' => $this
        ->t('Absolute year'),
      'month' => $this
        ->t('Absolute month'),
      'day' => $this
        ->t('Absolute day'),
      'second' => $this
        ->t('Datetime'),
    ],
    '#required' => TRUE,
    '#default_value' => $this->options['value_granularity'],
  ];
  $minDefault = isset($this->options['value_min']) ? DrupalDateTime::createFromFormat(\DATE_ISO8601, $this->options['value_min']) : NULL;
  $form['value_minimum'] = [
    '#title' => $this
      ->t('Minimum date'),
    '#description' => $this
      ->t('Minimum date to use. If a larger granularity than <em>seconds</em> is chosen, this date will be rounded off. For example if this date and time is in September 2018 but the granularity is <em>year</em>, then the minimum year would be 2018.'),
    '#type' => 'datetime',
    '#default_value' => $minDefault,
  ];
  $maxDefault = isset($this->options['value_max']) ? DrupalDateTime::createFromFormat(\DATE_ISO8601, $this->options['value_max']) : NULL;
  $form['value_maximum'] = [
    '#title' => $this
      ->t('Maximum date'),
    '#description' => $this
      ->t('Maximum date to use. If a larger granularity than <em>seconds</em> is chosen, this date will be rounded off. For example if this date and time is in September 2018 but the granularity is <em>year</em>, then the maximum year would be 2018.'),
    '#type' => 'datetime',
    '#default_value' => $maxDefault,
  ];
}