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);