@@ -133,7 +133,10 @@ Notice that you embed a collection of ``TagType`` forms using the
133133 {
134134 $builder->add('description');
135135
136- $builder->add('tags', 'collection', array('type' => new TagType()));
136+ $builder->add('tags', 'collection', array(
137+ 'type' => new TagType(),
138+ 'options' => array('label' => false)
139+ ));
137140 }
138141
139142 public function configureOptions(OptionsResolver $resolver)
@@ -290,9 +293,10 @@ add the ``allow_add`` option to your collection field::
290293 public function buildForm(FormBuilderInterface $builder, array $options)
291294 {
292295 $builder->add('description');
293-
296+
294297 $builder->add('tags', 'collection', array(
295298 'type' => new TagType(),
299+ 'options' => array('label' => false),
296300 'allow_add' => true,
297301 ));
298302 }
@@ -399,9 +403,15 @@ one example:
399403 // get the new index
400404 var index = $collectionHolder .data (' index' );
401405
406+ var newForm = prototype;
407+ // You need this only if you didn't set 'label' => false in your tags field in TaskType
408+ // Replace '__name__label__' in the prototype's HTML to
409+ // instead be a number based on how many items we have
410+ // newForm = newForm.replace(/__name__label__/g, index);
411+
402412 // Replace '__name__' in the prototype's HTML to
403413 // instead be a number based on how many items we have
404- var newForm = prototype .replace (/ __name__/ g , index);
414+ newForm = newForm .replace (/ __name__/ g , index);
405415
406416 // increase the index with one for the next item
407417 $collectionHolder .data (' index' , index + 1 );
0 commit comments