Skip to content

Commit 9dfd616

Browse files
committed
Guard edit button script against missing edit route in ModelListType
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).
1 parent f8b0965 commit 9dfd616

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Resources/views/CRUD/Association/edit_many_script.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ This code manages the many-to-[one|many] association field popup
560560
if (undefined === objectId || null === objectId || '' === objectId) {
561561
jQuery('#field_widget_{{ id }}').html('{{ 'short_object_description_placeholder'|trans({}, 'SonataAdminBundle') }}');
562562
563-
{% if btn_edit %}
563+
{% if associationadmin.hasroute('edit') and associationadmin.hasAccess('edit') and btn_edit %}
564564
jQuery('#field_actions_{{ id }} a.btn-warning').addClass('hidden');
565565
{% endif %}
566566
@@ -587,7 +587,7 @@ This code manages the many-to-[one|many] association field popup
587587
}
588588
});
589589
590-
{% if btn_edit %}
590+
{% if associationadmin.hasroute('edit') and associationadmin.hasAccess('edit') and btn_edit %}
591591
var edit_button_url = '{{
592592
associationadmin.generateUrl('edit', {(associationadmin.idParameter) : 'OBJECT_ID'})
593593
}}'.replace('OBJECT_ID', objectId);

0 commit comments

Comments
 (0)