Skip to content

Commit c8deb3d

Browse files
Cristoforo Cervinowouterj
Cristoforo Cervino
authored andcommitted
add form_attr option doc
1 parent d5173b0 commit c8deb3d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

reference/forms/types/form.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on all types for which ``FormType`` is the parent.
1919
| | - `error_bubbling`_ |
2020
| | - `error_mapping`_ |
2121
| | - `extra_fields_message`_ |
22+
| | - `form_attr`_ |
2223
| | - `help`_ |
2324
| | - `help_attr`_ |
2425
| | - `help_html`_ |
@@ -116,6 +117,8 @@ The actual default value of this option depends on other field options:
116117

117118
.. include:: /reference/forms/types/options/extra_fields_message.rst.inc
118119

120+
.. include:: /reference/forms/types/options/form_attr.rst.inc
121+
119122
.. include:: /reference/forms/types/options/help.rst.inc
120123

121124
.. include:: /reference/forms/types/options/help_attr.rst.inc
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
``form_attr``
2+
~~~~~~~~~~~~~
3+
4+
**type**: ``boolean`` or ``string`` **default**: ``false``
5+
6+
When ``true`` and used on a form element, it adds a `"form" attribute`_ to its HTML field representation with
7+
its HTML form id. By doing this, a form element can be rendered outside the HTML form while still working as expected::
8+
9+
$builder->add('body', TextareaType::class, [
10+
'form_attr' => true,
11+
]);
12+
13+
This can be useful when you need to solve nested form problems.
14+
You can also set this to ``true`` on a root form to automatically set the "form" attribute on all its children.
15+
16+
.. note::
17+
18+
When the root form has no ID, ``form_attr`` is required to be a string identifier to be used as the form ID.
19+
20+
.. _`"form" attribute`: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form

0 commit comments

Comments
 (0)