File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,30 @@ array).
217217
218218 <option {% if choice is selectedchoice(value) %} selected="selected"{% endif %} ...>
219219
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+
220244 .. _`twig-reference-form-variables` :
221245
222246More about Form Variables
Original file line number Diff line number Diff line change @@ -750,6 +750,19 @@ selectedchoice
750750Checks if ``selectedValue `` was checked for the provided choice field. Using
751751this test is the most effective way.
752752
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+
753766Global Variables
754767----------------
755768
You can’t perform that action at this time.
0 commit comments