Skip to content

Commit 44e6e65

Browse files
committed
[Form] Add new prototype_options
1 parent 5c6a13a commit 44e6e65

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

reference/forms/types/collection.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,29 @@ type::
303303
],
304304
]);
305305

306+
prototype_options
307+
~~~~~~~~~~~~~~~~~
308+
309+
**type**: ``array`` **default**: ``[]``
310+
311+
This is the array that's passed to the form type specified in the `entry_type`_
312+
option when creating its prototype. It allows to have different options depending
313+
on whether you are adding a new entry or editing an existing entry.
314+
315+
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
316+
use Symfony\Component\Form\Extension\Core\Type\TextType;
317+
// ...
318+
319+
$builder->add('names', CollectionType::class, [
320+
'entry_type' => TextType::class,
321+
'entry_options' => [
322+
'help' => 'You can edit this name here.',
323+
],
324+
'prototype_options' => [
325+
'help' => 'You can enter a new name here.',
326+
],
327+
]);
328+
306329
entry_type
307330
~~~~~~~~~~
308331

0 commit comments

Comments
 (0)