function Date::buildOptionsForm

Same name in this branch
  1. 9 core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date::buildOptionsForm()
Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date::buildOptionsForm()
  2. 8.9.x core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date::buildOptionsForm()
  3. 10 core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date::buildOptionsForm()
  4. 10 core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date::buildOptionsForm()
  5. 11.x core/modules/views/src/Plugin/views/sort/Date.php \Drupal\views\Plugin\views\sort\Date::buildOptionsForm()
  6. 11.x core/modules/views/src/Plugin/views/field/Date.php \Drupal\views\Plugin\views\field\Date::buildOptionsForm()

Overrides SortPluginBase::buildOptionsForm

File

core/modules/views/src/Plugin/views/sort/Date.php, line 25

Class

Date
Basic sort handler for dates.

Namespace

Drupal\views\Plugin\views\sort

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $form['granularity'] = [
        '#type' => 'radios',
        '#title' => $this->t('Granularity'),
        '#options' => [
            'second' => $this->t('Second'),
            'minute' => $this->t('Minute'),
            'hour' => $this->t('Hour'),
            'day' => $this->t('Day'),
            'month' => $this->t('Month'),
            'year' => $this->t('Year'),
        ],
        '#description' => $this->t('The granularity is the smallest unit to use when determining whether two dates are the same; for example, if the granularity is "Year" then all dates in 1999, regardless of when they fall in 1999, will be considered the same date.'),
        '#default_value' => $this->options['granularity'],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.