Skip to content
Snippets Groups Projects
Commit 36eab853 authored by Owen Bush's avatar Owen Bush
Browse files

Adding back button functionality. Fixing a number of bugs.

parent 505edc53
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ class EventSeriesEditForm extends EventSeriesForm { ...@@ -25,6 +25,7 @@ class EventSeriesEditForm extends EventSeriesForm {
/* @var $entity \Drupal\recurring_events\Entity\EventSeries */ /* @var $entity \Drupal\recurring_events\Entity\EventSeries */
$entity = $this->entity; $entity = $this->entity;
// Determine if there have been changes to the saved eventseries.
$creation_service = \Drupal::service('recurring_events.event_creation_service'); $creation_service = \Drupal::service('recurring_events.event_creation_service');
$diff_array = $creation_service->buildDiffArray($entity, $form_state); $diff_array = $creation_service->buildDiffArray($entity, $form_state);
...@@ -75,6 +76,7 @@ class EventSeriesEditForm extends EventSeriesForm { ...@@ -75,6 +76,7 @@ class EventSeriesEditForm extends EventSeriesForm {
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->t('Back'), '#value' => $this->t('Back'),
]; ];
$form['actions']['delete']['#printed'] = TRUE; $form['actions']['delete']['#printed'] = TRUE;
} }
...@@ -92,7 +94,18 @@ class EventSeriesEditForm extends EventSeriesForm { ...@@ -92,7 +94,18 @@ class EventSeriesEditForm extends EventSeriesForm {
$form_state->setRebuild(); $form_state->setRebuild();
} }
else { else {
parent::submitForm($form, $form_state); $triggering_element = $form_state->getTriggeringElement();
switch ($triggering_element['#id']) {
case 'edit-back':
$this->step--;
$form_state->setRebuild();
break;
case 'edit-submit':
parent::submitForm($form, $form_state);
break;
}
} }
} }
......
...@@ -24,7 +24,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget { ...@@ -24,7 +24,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget {
*/ */
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state); $element = parent::formElement($items, $delta, $element, $form, $form_state);
$element['#type'] = 'container';
$element['#states'] = [ $element['#states'] = [
'visible' => [ 'visible' => [
':input[name="recur_type"]' => ['value' => 'monthly'], ':input[name="recur_type"]' => ['value' => 'monthly'],
...@@ -52,7 +52,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget { ...@@ -52,7 +52,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget {
'fourth' => t('Fourth'), 'fourth' => t('Fourth'),
'last' => t('Last'), 'last' => t('Last'),
], ],
'#default_value' => $items[$delta]->day_occurrence ? explode(',', $items[$delta]->day_occurrence) : '', '#default_value' => $items[$delta]->day_occurrence ? explode(',', $items[$delta]->day_occurrence) : [],
'#states' => [ '#states' => [
'visible' => [ 'visible' => [
':input[name="monthly_recurring_date[0][type]"]' => ['value' => 'weekday'], ':input[name="monthly_recurring_date[0][type]"]' => ['value' => 'weekday'],
...@@ -66,7 +66,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget { ...@@ -66,7 +66,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget {
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#title' => t('Days of the Week'), '#title' => t('Days of the Week'),
'#options' => $days, '#options' => $days,
'#default_value' => $items[$delta]->days ? explode(',', $items[$delta]->days) : '', '#default_value' => $items[$delta]->days ? explode(',', $items[$delta]->days) : [],
'#states' => [ '#states' => [
'visible' => [ 'visible' => [
':input[name="monthly_recurring_date[0][type]"]' => ['value' => 'weekday'], ':input[name="monthly_recurring_date[0][type]"]' => ['value' => 'weekday'],
...@@ -80,7 +80,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget { ...@@ -80,7 +80,7 @@ class MonthlyRecurringDateWidget extends WeeklyRecurringDateWidget {
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#title' => t('Days of the Month'), '#title' => t('Days of the Month'),
'#options' => $month_days, '#options' => $month_days,
'#default_value' => $items[$delta]->day_of_month ? explode(',', $items[$delta]->day_of_month) : '', '#default_value' => $items[$delta]->day_of_month ? explode(',', $items[$delta]->day_of_month) : [],
'#states' => [ '#states' => [
'visible' => [ 'visible' => [
':input[name="monthly_recurring_date[0][type]"]' => ['value' => 'monthday'], ':input[name="monthly_recurring_date[0][type]"]' => ['value' => 'monthday'],
......
...@@ -26,6 +26,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget { ...@@ -26,6 +26,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state); $element = parent::formElement($items, $delta, $element, $form, $form_state);
$element['#type'] = 'container';
$element['#states'] = [ $element['#states'] = [
'visible' => [ 'visible' => [
':input[name="recur_type"]' => ['value' => 'weekly'], ':input[name="recur_type"]' => ['value' => 'weekly'],
...@@ -69,7 +70,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget { ...@@ -69,7 +70,7 @@ class WeeklyRecurringDateWidget extends DateRangeDefaultWidget {
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#title' => t('Days of the Week'), '#title' => t('Days of the Week'),
'#options' => $days, '#options' => $days,
'#default_value' => $items[$delta]->days ? explode(',', $items[$delta]->days) : '', '#default_value' => $items[$delta]->days ? explode(',', $items[$delta]->days) : [],
'#weight' => 5, '#weight' => 5,
]; ];
......
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