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

Skip to content

[Form] added prototype_data option in CollectionType #6450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ photos).
| | - `entry_options`_ |
| | - `entry_type`_ |
| | - `prototype`_ |
| | - `prototype_data`_ |
| | - `prototype_name`_ |
+-------------+-----------------------------------------------------------------------------+
| Inherited | - `by_reference`_ |
Expand Down Expand Up @@ -363,6 +364,31 @@ rendering your form, having the entire "form row" may be easier for you.
For details on how to actually use this option, see the above example as
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 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