protected function DateRecurModularWidgetFieldsTrait::getFieldMonth in Recurring Date Field Modular Widgets 2.x
Same name and namespace in other branches
- 8 src/DateRecurModularWidgetFieldsTrait.php \Drupal\date_recur_modular\DateRecurModularWidgetFieldsTrait::getFieldMonth()
- 3.x src/DateRecurModularWidgetFieldsTrait.php \Drupal\date_recur_modular\DateRecurModularWidgetFieldsTrait::getFieldMonth()
Get a BYMONTH element.
Parameters
\Drupal\date_recur\DateRecurRuleInterface|null $rule: Optional rule for which default value is derived.
Return value
array A render array.
File
- src/
DateRecurModularWidgetFieldsTrait.php, line 46
Class
- DateRecurModularWidgetFieldsTrait
- Trait containing convenience methods for generating whole form fields.
Namespace
Drupal\date_recur_modularCode
protected function getFieldMonth(?DateRecurRuleInterface $rule) : array {
$parts = $rule ? $rule
->getParts() : [];
$monthOptions = DateHelper::monthNames(TRUE);
$monthDefault = isset($parts['BYMONTH']) ? explode(',', $parts['BYMONTH']) : [];
return [
'#type' => 'checkboxes',
'#title' => $this
->t('Months'),
'#title_display' => 'invisible',
'#options' => $monthOptions,
'#default_value' => $monthDefault,
];
}