diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index c5572f93c6b..9b00ab9a5bc 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -303,6 +303,29 @@ type:: ], ]); +prototype_options +~~~~~~~~~~~~~~~~~ + +**type**: ``array`` **default**: ``[]`` + +This is the array that's passed to the form type specified in the `entry_type`_ +option when creating its prototype. It allows to have different options depending +on whether you are adding a new entry or editing an existing entry. + + use Symfony\Component\Form\Extension\Core\Type\CollectionType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + // ... + + $builder->add('names', CollectionType::class, [ + 'entry_type' => TextType::class, + 'entry_options' => [ + 'help' => 'You can edit this name here.', + ], + 'prototype_options' => [ + 'help' => 'You can enter a new name here.', + ], + ]); + entry_type ~~~~~~~~~~