Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c08e10

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

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

reference/forms/types/collection.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,28 @@ well as :ref:`cookbook-form-collections-new-prototype`.
367367
prototype_data
368368
~~~~~~~~~~~~~~
369369

370+
.. versionadded:: 2.8
371+
The ``prototype_data`` option was introduced in Symfony 2.8.
372+
370373
**type**: ``mixed`` **default**: ``null``
371374

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

0 commit comments

Comments
 (0)