@@ -130,7 +130,8 @@ Notice that you embed a collection of ``TagType`` forms using the
130130 $builder->add('description');
131131
132132 $builder->add('tags', CollectionType::class, array(
133- 'entry_type' => TagType::class
133+ 'entry_type' => TagType::class,
134+ 'entry_options' => array('label' => false),
134135 ));
135136 }
136137
@@ -285,8 +286,9 @@ add the ``allow_add`` option to your collection field::
285286 $builder->add('description');
286287
287288 $builder->add('tags', CollectionType::class, array(
288- 'entry_type' => TagType::class,
289- 'allow_add' => true,
289+ 'entry_type' => TagType::class,
290+ 'entry_options' => array('label' => false),
291+ 'allow_add' => true,
290292 ));
291293 }
292294
@@ -392,9 +394,15 @@ one example:
392394 // get the new index
393395 var index = $collectionHolder .data (' index' );
394396
397+ var newForm = prototype;
398+ // You need this only if you didn't set 'label' => false in your tags field in TaskType
399+ // Replace '__name__label__' in the prototype's HTML to
400+ // instead be a number based on how many items we have
401+ // newForm = newForm.replace(/__name__label__/g, index);
402+
395403 // Replace '__name__' in the prototype's HTML to
396404 // instead be a number based on how many items we have
397- var newForm = prototype .replace (/ __name__/ g , index);
405+ newForm = newForm .replace (/ __name__/ g , index);
398406
399407 // increase the index with one for the next item
400408 $collectionHolder .data (' index' , index + 1 );
0 commit comments