From e18dc1fc7d8dda5e257ab911b121d41cd8fc8efa Mon Sep 17 00:00:00 2001 From: Kristen Gilden Date: Fri, 24 Oct 2014 21:57:29 +0300 Subject: [PATCH 1/2] [Form] Document CollectionType's `prototype_data` --- reference/forms/types/collection.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index c9e237181b3..e3c9fece9c1 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -20,6 +20,7 @@ photos). | | - `entry_options`_ | | | - `entry_type`_ | | | - `prototype`_ | +| | - `prototype_data`_ | | | - `prototype_name`_ | +-------------+-----------------------------------------------------------------------------+ | Inherited | - `by_reference`_ | @@ -363,6 +364,14 @@ 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 +~~~~~~~~~~~~~~ + +**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. + prototype_name ~~~~~~~~~~~~~~ From 95bda572d77461edabb87c4ee12a91ac8b8461ea Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sat, 9 Apr 2016 13:47:25 +0200 Subject: [PATCH 2/2] [Form] defined default and added example CollectionType `prototype_data` option --- reference/forms/types/collection.rst | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index e3c9fece9c1..28d0fce9422 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -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; + // ... + + $builder->add('tags', CollectionType::class, array( + 'entry_type' => TextType::class, + 'allow_add' => true, + 'prototype' => true, + 'prototype_data' => 'New Tag Placeholder', + )); prototype_name ~~~~~~~~~~~~~~