Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Form] defined default and added example CollectionType `prototype_da…
…ta` option
  • Loading branch information
HeahDude committed Apr 14, 2016
commit 95bda572d77461edabb87c4ee12a91ac8b8461ea
21 changes: 19 additions & 2 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,27 @@ well as :ref:`cookbook-form-collections-new-prototype`.
prototype_data
~~~~~~~~~~~~~~

.. versionadded:: 2.8
The ``prototype_data`` option was introduced in Symfony 2.8.

**type**: ``mixed`` **default**: ``null``

Allows you to specify data for the prototype. Each new row added will initially
contain the data set by this option.
Allows you to define specific data for the prototype. Each new row added will
initially contain the data set by this option. By default, the data configured
for all entries with the ``entry_options`` option will be used.

.. code-block:: php

use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use statements are useless now. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I made another commit to do that change in all examples, so you can easily revert it in 3.0+ branches. Thanks!

// ...

$builder->add('tags', CollectionType::class, array(
'entry_type' => TextType::class,
'allow_add' => true,
'prototype' => true,
'prototype_data' => 'New Tag Placeholder',
));

prototype_name
~~~~~~~~~~~~~~
Expand Down