@@ -133,7 +133,10 @@ Notice that you embed a collection of ``TagType`` forms using the
133
133
{
134
134
$builder->add('description');
135
135
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
+ ));
137
140
}
138
141
139
142
public function configureOptions(OptionsResolver $resolver)
@@ -290,9 +293,10 @@ add the ``allow_add`` option to your collection field::
290
293
public function buildForm(FormBuilderInterface $builder, array $options)
291
294
{
292
295
$builder->add('description');
293
-
296
+
294
297
$builder->add('tags', 'collection', array(
295
298
'type' => new TagType(),
299
+ 'options' => array('label' => false),
296
300
'allow_add' => true,
297
301
));
298
302
}
@@ -399,9 +403,15 @@ one example:
399
403
// get the new index
400
404
var index = $collectionHolder .data (' index' );
401
405
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
+
402
412
// Replace '__name__' in the prototype's HTML to
403
413
// 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);
405
415
406
416
// increase the index with one for the next item
407
417
$collectionHolder .data (' index' , index + 1 );
0 commit comments