File tree Expand file tree Collapse file tree 3 files changed +25
-10
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +25
-10
lines changed
Original file line number Diff line number Diff line change @@ -19,13 +19,15 @@ forms, which is useful when creating forms that expose one-to-many relationships
19
19
| | - `allow_delete `_ |
20
20
| | - `prototype `_ |
21
21
| | - `prototype_name `_ |
22
+ | | - `delete_empty `_ |
22
23
+-------------+-----------------------------------------------------------------------------+
23
24
| Inherited | - `label `_ |
24
25
| | - `label_attr `_ |
25
26
| options | - `error_bubbling `_ |
26
27
| | - `error_mapping `_ |
27
28
| | - `by_reference `_ |
28
29
| | - `empty_data `_ |
30
+ | | - `required `_ |
29
31
| | - `mapped `_ |
30
32
+-------------+-----------------------------------------------------------------------------+
31
33
| Parent type | :doc: `form </reference/forms/types/form >` |
@@ -334,6 +336,16 @@ If you have several collections in your form, or worse, nested collections
334
336
you may want to change the placeholder so that unrelated placeholders are not
335
337
replaced with the same value.
336
338
339
+ delete_empty
340
+ ~~~~~~~~~~~~~~
341
+
342
+ **type **: ``Boolean `` **default **: ``false ``
343
+
344
+ If you want to explicitly remove entirely empty collection entries from your
345
+ form you have to set this option to true. Existing collection entries will
346
+ however only be deleted if you have `allow_delete `_ option enabled, otherwise
347
+ the empty values will be kept.
348
+
337
349
Inherited options
338
350
-----------------
339
351
@@ -359,4 +371,6 @@ error_bubbling
359
371
360
372
.. include :: /reference/forms/types/options/empty_data.rst.inc
361
373
374
+ .. include :: /reference/forms/types/options/required.rst.inc
375
+
362
376
.. include :: /reference/forms/types/options/mapped.rst.inc
Original file line number Diff line number Diff line change @@ -8,17 +8,13 @@ choice is selected.
8
8
9
9
The true default value of this option depends on the field options:
10
10
11
- * If ``compound `` is ``true`` and ``data_class`` is set, then ``new $data_class()``;
12
- * If ``compound `` is ``true`` and no ``data_class`` is set, then ``array()``;
13
- * If ``compound `` is ``false``, then ``null``.
11
+ * If ``required `` is ``true`` and ``data_class`` is set, then ``new $data_class()``;
12
+ * If ``required `` is ``true`` and no ``data_class`` is set, then ``array()``;
13
+ * If ``required `` is ``false``, then ``null``.
14
14
15
- .. tip::
16
15
17
- The ``compound`` option is set to ``true`` when the field actually represents
18
- a collection of fields (e.g. a form of fields).
19
-
20
- For example, if you want the ``gender`` field to be set to ``null`` when no
21
- value is selected, you can do it like this:
16
+ But you can customize this to your needs. For example, if you want the ``gender`` field to be
17
+ set to explicitly ``null`` when no value is selected, you can do it like this:
22
18
23
19
.. code-block:: php
24
20
Original file line number Diff line number Diff line change @@ -10,4 +10,9 @@ This is superficial and independent from validation. At best, if you let Symfony
10
10
guess your field type, then the value of this option will be guessed from
11
11
your validation information.
12
12
13
- .. _`HTML5 required attribute`: http : // diveintohtml5.info/forms.html
13
+ .. _`HTML5 required attribute`: http://diveintohtml5.info/forms.html
14
+
15
+ .. note::
16
+
17
+ The required option does also affect the way how empty data of your form is
18
+ being handled. For further details check the :doc:` empty_data</ reference/forms/types/options/empty_data.rst.inc> ` option.
You can’t perform that action at this time.
0 commit comments