diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index c9e237181b3..28d0fce9422 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,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; + // ... + + $builder->add('tags', CollectionType::class, array( + 'entry_type' => TextType::class, + 'allow_add' => true, + 'prototype' => true, + 'prototype_data' => 'New Tag Placeholder', + )); + prototype_name ~~~~~~~~~~~~~~