From 03d3423c11354263619c79aa1864c1fbd42f1068 Mon Sep 17 00:00:00 2001 From: Owen Bush <ojb@ukhhf.co.uk> Date: Tue, 2 Apr 2019 15:58:04 -0600 Subject: [PATCH] Fixing bugs --- .../src/Form/RegistrantForm.php | 2 +- src/EventCreationService.php | 6 ++++-- src/Form/EventSeriesForm.php | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/recurring_events_registration/src/Form/RegistrantForm.php b/modules/recurring_events_registration/src/Form/RegistrantForm.php index 2127787a..383d1b10 100644 --- a/modules/recurring_events_registration/src/Form/RegistrantForm.php +++ b/modules/recurring_events_registration/src/Form/RegistrantForm.php @@ -236,7 +236,7 @@ class RegistrantForm extends ContentEntityForm { '#weight' => 100, ]; - if ($this->currentUser->hasPermission('modify registrant waitlist')) { + if ($this->currentUser->hasPermission('modify registrant waitlist') && $waitlist) { $form['add_to_waitlist']['#type'] = 'select'; $form['add_to_waitlist']['#options'] = [ 1 => $this->t('Yes'), diff --git a/src/EventCreationService.php b/src/EventCreationService.php index 43a367e4..adbc7fa2 100644 --- a/src/EventCreationService.php +++ b/src/EventCreationService.php @@ -384,12 +384,14 @@ class EventCreationService { /** * Create an event based on the form submitted values. * + * @param Drupal\recurring_events\Entity\EventSeries $original + * The original, unsaved event series entity. * @param Drupal\recurring_events\Entity\EventSeries $event * The stored event series entity. * @param Drupal\Core\Form\FormStateInterface $form_state * The form state of an updated event series entity. */ - public function saveEvent(EventSeries $event, FormStateInterface $form_state) { + public function saveEvent(EventSeries $original, EventSeries $event, FormStateInterface $form_state) { // We only need a revision if this is an existing entity. if ($event->isNew()) { $create_instances = TRUE; @@ -399,7 +401,7 @@ class EventCreationService { } else { // If there are date differences, we need to clear out the instances. - $create_instances = $this->checkForRecurConfigChanges($event, $form_state); + $create_instances = $this->checkForRecurConfigChanges($original, $form_state); if ($create_instances) { // Find all the instances and delete them. $instances = $event->event_instances->referencedEntities(); diff --git a/src/Form/EventSeriesForm.php b/src/Form/EventSeriesForm.php index e61b647a..66fa0576 100644 --- a/src/Form/EventSeriesForm.php +++ b/src/Form/EventSeriesForm.php @@ -213,12 +213,13 @@ class EventSeriesForm extends ContentEntityForm { public function save(array $form, FormStateInterface $form_state) { $form_state->setRedirect('entity.eventseries.collection'); $entity = $this->getEntity(); + $original = $this->storage->loadUnchanged($entity->id()); $this->messenger->addStatus($this->t('Successfully saved the %name event series', [ '%name' => $entity->title->value, ])); - $this->creationService->saveEvent($entity, $form_state); + $this->creationService->saveEvent($original, $entity, $form_state); parent::save($form, $form_state); } -- GitLab