Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd433a1

Browse files
committed
Document Twig test "rootform"
1 parent6d940aa commitfd433a1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

‎reference/forms/twig_reference.rst‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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

222246
More about Form Variables

‎reference/twig_reference.rst‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,19 @@ selectedchoice
750750
Checks if ``selectedValue`` was checked for the provided choice field. Using
751751
this 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+
753766
Global Variables
754767
----------------
755768

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp