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

Appearance settings

Commit c8deb3d

Browse filesBrowse files
Cristoforo Cervinowouterj
Cristoforo Cervino
authored andcommitted
add form_attr option doc
1 parent d5173b0 commit c8deb3d
Copy full SHA for c8deb3d

File tree

2 files changed

+23
-0
lines changed
Filter options

2 files changed

+23
-0
lines changed

‎reference/forms/types/form.rst

Copy file name to clipboardExpand all lines: reference/forms/types/form.rst
+3Lines 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
+20Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.