From 915bc89e3d1b03c285fc23137ff00aa850689145 Mon Sep 17 00:00:00 2001 From: stoccc Date: Fri, 11 Aug 2017 11:55:11 +0200 Subject: [PATCH] form collection label not correct Fixes this https://github.com/symfony/symfony-docs/issues/6607 in 2.8 branch. See also https://github.com/symfony/symfony-docs/pull/8280 --- form/form_collections.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/form/form_collections.rst b/form/form_collections.rst index 8fee674363a..e928b7e5605 100644 --- a/form/form_collections.rst +++ b/form/form_collections.rst @@ -130,7 +130,8 @@ Notice that you embed a collection of ``TagType`` forms using the $builder->add('description'); $builder->add('tags', CollectionType::class, array( - 'entry_type' => TagType::class + 'entry_type' => TagType::class, + 'entry_options' => array('label' => false) )); } @@ -286,6 +287,7 @@ add the ``allow_add`` option to your collection field:: $builder->add('tags', CollectionType::class, array( 'entry_type' => TagType::class, + 'entry_options'=> array('label' => false), 'allow_add' => true, )); } @@ -392,9 +394,15 @@ one example: // get the new index var index = $collectionHolder.data('index'); + var newForm = prototype; + // You need this only if you didn't set 'label' => false in your tags field in TaskType + // Replace '__name__label__' in the prototype's HTML to + // instead be a number based on how many items we have + // newForm = newForm.replace(/__name__label__/g, index); + // Replace '__name__' in the prototype's HTML to // instead be a number based on how many items we have - var newForm = prototype.replace(/__name__/g, index); + newForm = newForm.replace(/__name__/g, index); // increase the index with one for the next item $collectionHolder.data('index', index + 1);