Skip to content

Commit

Permalink
[civiremote_entity] Stay on form page in case of error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dominic Tubach committed Sep 20, 2024
1 parent 04ffb01 commit d1e46d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/civiremote_entity/src/Form/AbstractEntityForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d1e46d8

Please sign in to comment.