Repository navigation
Conversation
phcorp
force-pushed
the
fix_redirect_after_save_without_button
branch
2 times, most recently
from
November 7, 2026 02:06
4cddd3e to
041340f
Compare
getRedirectResponseAfterSave() chooses the redirect from the name of the submit button (ea[newForm][btn]). When a new or edit form is submitted without any of its buttons, e.g. with form.submit() in JavaScript or by a browser extension, that parameter is missing and the user was redirected to the dashboard, which is not what any of the form buttons does. A missing button name is now handled as the main button of the form (Action::SAVE_AND_RETURN), so the user goes back to the index page. The getRedirectResponseAfterSave() example of the docs now also handles a missing button name, as reading it without a default triggers a warning.
phcorp
force-pushed
the
fix_redirect_after_save_without_button
branch
from
November 8, 2026 19:51
041340f to
0e4c1c5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AbstractCrudController::getRedirectResponseAfterSave()picks the redirect from the submit button that was clicked (ea[newForm][btn]). A browser only sends that parameter when the form is submitted with one of its buttons. When a new/edit form is submitted another way, e.g.form.submit()in JavaScript or a browser extension, the parameter is missing and thematchfalls into itsdefaultbranch. That branch redirects to the dashboard, which none of the form buttons does.Also, the
getRedirectResponseAfterSave()example indoc/crud.rstreads['btn']with no default, which triggers an "Undefined array key" warning in that case.Fix
Action::SAVE_AND_RETURN, so the user goes back to the index page.?? null.Tests
NewTest::testRedirectAfterCreationDependsOnTheSubmitButton()andEditTest::testRedirectAfterUpdateDependsOnTheSubmitButton()(DefaultApp,Category) cover:/adminon5.xand now redirects to the index URLResults:
make tests ARGS="tests/Functional/Default/Crud/": OK (75 tests)make tests-parallel: OK (3692 tests)