From d1e46d8476af63c923609f9bb02caf5b0fce978a Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Fri, 20 Sep 2024 11:52:45 +0200 Subject: [PATCH] [civiremote_entity] Stay on form page in case of error Previously on error a redirect to the destination (URL parameter) was executed, if given. Otherwise, a redirect to the form page was executed. Now in both cases a redirect to the form page is executed, if Drupal >= 10 is used. --- modules/civiremote_entity/src/Form/AbstractEntityForm.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/civiremote_entity/src/Form/AbstractEntityForm.php b/modules/civiremote_entity/src/Form/AbstractEntityForm.php index 93b810a..2c9b864 100644 --- a/modules/civiremote_entity/src/Form/AbstractEntityForm.php +++ b/modules/civiremote_entity/src/Form/AbstractEntityForm.php @@ -119,6 +119,10 @@ public function submitForm(array &$form, FormStateInterface $formState): void { } catch (ApiCallFailedException $e) { $this->messenger()->addError($this->t('Submitting form failed: @error', ['@error' => $e->getMessage()])); + if (method_exists($formState, 'setIgnoreDestination')) { + // Method is not available in Drupal 9. + $formState->setIgnoreDestination(TRUE); + } return; }