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 95bda57

Browse filesBrowse files
committed
[Form] defined default and added example CollectionType prototype_data option
1 parent e18dc1f commit 95bda57
Copy full SHA for 95bda57

File tree

1 file changed

+19
-2
lines changed
Filter options

1 file changed

+19
-2
lines changed

‎reference/forms/types/collection.rst

Copy file name to clipboardExpand all lines: reference/forms/types/collection.rst
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,27 @@ 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+
'entry_type' => TextType::class,
387+
'allow_add' => true,
388+
'prototype' => true,
389+
'prototype_data' => 'New Tag Placeholder',
390+
));
374391
375392
prototype_name
376393
~~~~~~~~~~~~~~

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.