File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,27 @@ you'd use the :doc:`EmailType </reference/forms/types/email>`. If you want
229
229
to embed a collection of some other form, pass the form type class as this
230
230
option (e.g. ``MyFormType::class ``).
231
231
232
+ keep_as_list
233
+ ~~~~~~~~~~~~
234
+
235
+ **type **: ``boolean `` **default **: ``false ``
236
+
237
+ When set to ``true ``, the ``keep_as_list `` option affects the reindexing
238
+ of nested form names within a collection. This feature is particularly useful
239
+ when working with collection types and removing items from the collection
240
+ during form submission.
241
+
242
+ When this option is set to ``false ``, if you have a collection of 3 items and
243
+ you remove the second item, the indexes will be ``0 `` and ``2 `` when validating
244
+ the collection. However, by enabling the ``keep_as_list `` option and setting
245
+ it to ``true ``, the indexes will be reindexed as ``0 `` and ``1 ``. This ensures
246
+ that the indexes remain consecutive and do not have gaps, providing a clearer
247
+ and more predictable structure for your nested forms.
248
+
249
+ .. versionadded :: 7.1
250
+
251
+ The ``keep_as_list `` option was introduced in Symfony 7.1.
252
+
232
253
prototype
233
254
~~~~~~~~~
234
255
You can’t perform that action at this time.
0 commit comments