Skip to content

Commit 915bc89

Browse files
authored
form collection label not correct
Fixes this symfony#6607 in 2.8 branch. See also symfony#8280
1 parent 712fd4c commit 915bc89

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

form/form_collections.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -286,6 +287,7 @@ add the ``allow_add`` option to your collection field::
286287

287288
$builder->add('tags', CollectionType::class, array(
288289
'entry_type' => TagType::class,
290+
'entry_options'=> array('label' => false),
289291
'allow_add' => true,
290292
));
291293
}
@@ -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

Comments
 (0)