protected function CalenderOverviewFilterForm::addCalendarYearSelectBox in Content Planner 8
Add Calendar select box.
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $formState:
$params:
1 call to CalenderOverviewFilterForm::addCalendarYearSelectBox()
- CalenderOverviewFilterForm::buildForm in modules/
content_calendar/ src/ Form/ CalenderOverviewFilterForm.php - Form constructor.
File
- modules/
content_calendar/ src/ Form/ CalenderOverviewFilterForm.php, line 40
Class
Namespace
Drupal\content_calendar\FormCode
protected function addCalendarYearSelectBox(array &$form, FormStateInterface &$formState, $params) {
// Date range.
$year_range = range($params['current_year'] - 3, $params['current_year'] + 3);
$years = array_combine($year_range, $year_range);
$form['calendar_year'] = [
'#type' => 'select',
'#options' => $years,
'#required' => TRUE,
'#default_value' => $params['selected_year'],
];
}