Guard edit button script against missing edit route in ModelListType - #8382
Merged
VincentLanglet merged 1 commit intoJun 3, 2026
Conversation
When a ModelListType field points to an admin whose edit route was removed in
configureRoutes(), the edit_many_script template still generated the edit URL
because it was guarded by btn_edit only, throwing "unable to find the route"
while rendering the form. Align the guards with the visible button in
form_admin_fields.html.twig (hasroute('edit') and hasAccess('edit') and btn_edit).
EmmanuelVella
force-pushed
the
fix/model-list-edit-script-missing-route
branch
from
June 1, 2026 13:24
9dfd616 to
fd3ae0e
Compare
EmmanuelVella
marked this pull request as draft
June 1, 2026 13:24
EmmanuelVella
marked this pull request as ready for review
June 1, 2026 13:26
Contributor
|
PHPUnit test fails are unrelated and also happen on 4.x with Symfony 8.1 |
VincentLanglet
approved these changes
Jun 3, 2026
Member
|
Thanks |
Contributor
Author
|
Thank you ! |
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.
Subject
When a
ModelListType(sonata_type_model_list) field points to an admin whoseeditroute has beenremoved in
configureRoutes(), rendering the edit form throwsRuntimeException: unable to find the route "<admin>.edit".The visible edit button in
Form/form_admin_fields.html.twigis correctly guarded byhasroute('edit') and hasAccess('edit') and btn_edit, but the companion script inCRUD/Association/edit_many_script.html.twigguarded theassociationadmin.generateUrl('edit', ...)call (and the related
btn-warningtoggle) withbtn_editonly. Asbtn_editdefaults to the truthy'link_edit', the URL generation runs even when the route does not exist, crashing the whole formrendering.
This aligns the script's guards with the widget's, so the edit URL is only generated when the associated
admin actually has an accessible
editroute.I am targeting this branch, because it is a backwards-compatible bugfix.
Steps to reproduce
configureRoutes()calls$collection->remove('edit').ModelListTypeform field, and set a value on that field.RuntimeException: unable to find the route "...edit".Changelog