File tree 2 files changed +29
-0
lines changed
Filter options
2 files changed +29
-0
lines changed
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ on all types for which ``FormType`` is the parent.
19
19
| | - `error_bubbling `_ |
20
20
| | - `error_mapping `_ |
21
21
| | - `extra_fields_message `_ |
22
+ | | - `form_attr `_ |
22
23
| | - `help `_ |
23
24
| | - `help_attr `_ |
24
25
| | - `help_html `_ |
@@ -116,6 +117,8 @@ The actual default value of this option depends on other field options:
116
117
117
118
.. include :: /reference/forms/types/options/extra_fields_message.rst.inc
118
119
120
+ .. include :: /reference/forms/types/options/form_attr.rst.inc
121
+
119
122
.. include :: /reference/forms/types/options/help.rst.inc
120
123
121
124
.. include :: /reference/forms/types/options/help_attr.rst.inc
Original file line number Diff line number Diff line change
1
+ ``form_attr``
2
+ ~~~~~~~~~~~~~
3
+
4
+ **type**: ``bool`` 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, form element can be rendered outside 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 root form has no ID, ``form_attr`` required to be a string identifier to be used as form ID.
19
+
20
+ .. caution::
21
+
22
+ HTML "form" attribute was introduced to let you explicitly bind a control with a form even if it is
23
+ not nested inside it. Don't forget to check for `browser compatibility`_.
24
+
25
+ .. _`"form" attribute`: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form
26
+ .. _`browser compatibility`: https://caniuse.com/form-attribute
You can’t perform that action at this time.
0 commit comments