8000 [Form] defined default and added example CollectionType `prototype_da… · symfony/symfony-docs@6f15771 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6f15771

Browse files
committed
[Form] defined default and added example CollectionType prototype_data option
1 parent f6fe783 commit 6f15771

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

reference/forms/types/collection.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,23 @@ prototype_data
369369

370370
**type**: ``mixed`` **default**: ``null``
371371

372-
Allows you to specify data for the prototype. Each new row added will initially
373-
contain the data set by this option.
372+
Allows you to define a specific data for the prototype. Each new row added will
373+
initially contain the data set by this option.
374+
By default, the same data as defined with ``entry_options`` for other entries
375+
will be used.
376+
377+
.. code-block:: php
378+
379+
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
380+
use Symfony\Component\Form\Extension\Core\Type\TextType;
381+
382+
$builder->add('tags', CollectionType::class, array(
383+
'class' => \AppBundle\Entity\Tag::class,
384+
'entry_type' => TextType::class,
385+
'allow_add' => true,
386+
'prototype' => true,
387+
'prototype_data' => 'New Tag Placeholder',
388+
));
374389
375390
prototype_name
376391
~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)
0