From b1c5591c0fa592a85c1054298f120963c429db53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Tue, 5 Nov 2024 12:24:53 +0100 Subject: [PATCH] Fix form without data id --- .../templates/shared/crud/common/content/form.html.twig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BootstrapAdminUi/templates/shared/crud/common/content/form.html.twig b/src/BootstrapAdminUi/templates/shared/crud/common/content/form.html.twig index 5b38bfea..0a2dc286 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/common/content/form.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/common/content/form.html.twig @@ -2,6 +2,10 @@ {% set form = hookable_metadata.context.form %} {% endif %} +{% if resource is not defined %} + {% set resource = hookable_metadata.context.resource %} +{% endif %} + {% form_theme form '@SyliusBootstrapAdminUi/shared/form_theme.html.twig' %}
@@ -9,13 +13,13 @@
{% if hookable_metadata.configuration.method is defined %} - {% elseif form.vars.data.id is not null %} + {% elseif form.vars.data.id|default(null) is not null %} {% endif %} {{ form_errors(form) }} {{ form_widget(form._token) }} - {% hook 'form' with { form } %} + {% hook 'form' with { form, resource } %}
{{ form_end(form, {render_rest: hookable_metadata.configuration.render_rest|default(false)}) }}