Skip to content
Snippets Groups Projects
Commit c9d0cd29 authored by Darren Moves's avatar Darren Moves Committed by Owen Bush
Browse files

Issue #3173381 by the_glitch, owenbush: Series Type Manage Form Display -...

Issue #3173381 by the_glitch, owenbush: Series Type Manage Form Display - Show/Hide 'Enable Wailing List' option
parent 6098f176
No related branches found
No related tags found
No related merge requests found
......@@ -80,3 +80,11 @@ recurring_events_registration.registrant.config:
series_modification_notification_body:
type: string
label: 'The email body for the series modification emails'
field.widget.settings.event_registration:
type: mapping
label: 'Recurring Events Show Enable Waitlist'
mapping:
show_enable_waitlist:
type: boolean
label: 'Enable Waiting List'
......@@ -22,6 +22,45 @@ class EventRegistrationWidget extends DateRangeDefaultWidget {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return [
'show_enable_waitlist' => TRUE,
] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['show_enable_waitlist'] = [
'#type' => 'radios',
'#options' => [
'1' => $this->t('Show'),
'0' => $this->t('Hide')
],
'#title' => $this->t('Enable Waiting List'),
'#default_value' => $this->getSetting('show_enable_waitlist'),
'#description' => $this->t('This will show/hide the "Enable Waiting List" checkbox in the Add/Edit Series form')
];
return $element;
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = [];
$enable_waitlist = $this->getSetting('show_enable_waitlist') ? $this->t('On') : $this->t('Off');
$summary[] = $this->t('Enable Waiting list is: @value', array('@value' => $enable_waitlist));
return $summary;
}
/**
* {@inheritdoc}
*/
......@@ -231,17 +270,21 @@ class EventRegistrationWidget extends DateRangeDefaultWidget {
],
];
$enable_waitlist = $this->getSetting('show_enable_waitlist');
$waitlist_default_value = $enable_waitlist ? ($items[$delta]->waitlist ?? FALSE) : FALSE;
$items[$delta]->waitlist = 1;
$element['waitlist'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable Waiting List'),
'#description' => $this->t('Enable a waiting list if the number of registrations reaches capacity.'),
'#weight' => 6,
'#default_value' => $items[$delta]->waitlist ?: '',
'#default_value' => $waitlist_default_value,
'#states' => [
'visible' => [
':input[name="event_registration[0][registration]"]' => ['checked' => TRUE],
],
],
'#access' => $enable_waitlist ? TRUE : FALSE,
];
return $element;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment