Skip to content

Commit 0c9e462

Browse files
[Form] Add keep_as_list option
1 parent c7d3bf8 commit 0c9e462

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

reference/forms/types/collection.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,23 @@ you'd use the :doc:`EmailType </reference/forms/types/email>`. If you want
229229
to embed a collection of some other form, pass the form type class as this
230230
option (e.g. ``MyFormType::class``).
231231

232+
keep_as_list
233+
~~~~~~~~~~~~
234+
235+
**type**: ``boolean`` **default**: ``false``
236+
237+
If set to ``true``, the entries will be reindexed so their indexes follow each
238+
other. This is useful when you validate a collection type and an item was
239+
removed from the collection on submit. If you don't reindex the entries, the
240+
indexes may have gaps in them. For example, if you have a collection of 3
241+
items and you remove the second item, the indexes will be ``0`` and ``2`` when
242+
validating the collection. If you reindex the entries by setting the option
243+
to ``true``, the indexes will be ``0`` and ``1``.
244+
245+
.. versionadded:: 7.1
246+
247+
The ``keep_as_list`` option was introduced in Symfony 7.1.
248+
232249
prototype
233250
~~~~~~~~~
234251

0 commit comments

Comments
 (0)