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

Skip to content

Commit b11023f

Browse files
committed
feature #6450 [Form] added prototype_data option in CollectionType (kgilden, HeahDude)
This PR was merged into the 2.8 branch. Discussion ---------- [Form] added prototype_data option in CollectionType | Q | A | |----|----| | Branch | 2.8+ | | New doc | finishes #4367 | Commits ------- 95bda57 [Form] defined default and added example CollectionType `prototype_data` option e18dc1f [Form] Document CollectionType's `prototype_data`
2 parents 5726c9b + 95bda57 commit b11023f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

reference/forms/types/collection.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ photos).
2020
| | - `entry_options`_ |
2121
| | - `entry_type`_ |
2222
| | - `prototype`_ |
23+
| | - `prototype_data`_ |
2324
| | - `prototype_name`_ |
2425
+-------------+-----------------------------------------------------------------------------+
2526
| Inherited | - `by_reference`_ |
@@ -363,6 +364,31 @@ rendering your form, having the entire "form row" may be easier for you.
363364
For details on how to actually use this option, see the above example as
364365
well as :ref:`cookbook-form-collections-new-prototype`.
365366

367+
prototype_data
368+
~~~~~~~~~~~~~~
369+
370+
.. versionadded:: 2.8
371+
The ``prototype_data`` option was introduced in Symfony 2.8.
372+
373+
**type**: ``mixed`` **default**: ``null``
374+
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+
));
391+
366392
prototype_name
367393
~~~~~~~~~~~~~~
368394

0 commit comments

Comments
 (0)