From ec76b6aae824c14d0bf647a19abe10aabc281a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4fer?= Date: Sat, 2 Apr 2022 20:40:32 +0200 Subject: [PATCH] [Form] Add new prototype_options --- reference/forms/types/collection.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 ~~~~~~~~~~