Skip to content

form collection label not correct #8281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
));
}

Expand Down Expand Up @@ -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,
));
}
Expand Down Expand Up @@ -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);
Expand Down