File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,30 @@ array).
217
217
218
218
<option {% if choice is selectedchoice(value) %} selected="selected"{% endif %} ...>
219
219
220
+ .. _form-twig-rootform :
221
+
222
+ rootform
223
+ ~~~~~~~~
224
+
225
+ This test will check for sure if the current ``form `` does not have a parent form view.
226
+ It would avoid collision and odd behavior when your form has defined a ``parent `` field.
227
+
228
+ Wrong example if your form has a field named ``parent ``:
229
+
230
+ .. code-block :: jinja
231
+
232
+ {% if form.parent is null %}
233
+ {{ form_errors(form) }}
234
+ {% endif %}
235
+
236
+ Correct example, this will check for the parent form view rather than its ``parent `` field:
237
+
238
+ .. code-block :: jinja
239
+
240
+ {% if form is rootform %}
241
+ {{ form_errors(form) }}
242
+ {% endif %}
243
+
220
244
.. _`twig-reference-form-variables` :
221
245
222
246
More about Form Variables
Original file line number Diff line number Diff line change @@ -750,6 +750,19 @@ selectedchoice
750
750
Checks if ``selectedValue `` was checked for the provided choice field. Using
751
751
this test is the most effective way.
752
752
753
+ rootform
754
+ ~~~~~~~~
755
+
756
+ .. code-block :: twig
757
+
758
+ {% if form is rootform %}
759
+
760
+ ``form ``
761
+ **type **: ``FormView ``
762
+
763
+ Checks for sure if the current ``form `` does not have a parent form view. Using
764
+ this test is the safest way if your form contains a ``parent `` field.
765
+
753
766
Global Variables
754
767
----------------
755
768
You can’t perform that action at this time.
0 commit comments