-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
In Symfony\Component\Form\Extension\Core\Type\CollectionType::buildForm(), $options['entry_options'] where merged un final $options variable. But in 2.8.1, this key is not merged, so all entry_options specified in FormType are not passed to sub forms.
Old code (2.8.0) :
if ($options['allow_add'] && $options['prototype']) {
$prototype = $builder->create($options['prototype_name'], $options['entry_type'], array_replace(array(
'label' => $options['prototype_name'].'label__',
), $options['entry_options'], array(
'data' => $options['prototype_data'],
)));
$builder->setAttribute('prototype', $prototype->getForm());
}
New code (2.8.1), at line 5, $options['options'] is used but it's $options['entry_options'] instead :
if ($options['allow_add'] && $options['prototype']) {
$prototypeOptions = array_replace(array(
'required' => $options['required'],
'label' => $options['prototype_name'].'label__',
), $options['options']);
if (null !== $options['prototype_data']) {
$prototypeOptions['data'] = $options['prototype_data'];
}
$prototype = $builder->create($options['prototype_name'], $options['entry_type'], $prototypeOptions);
$builder->setAttribute('prototype', $prototype->getForm());
}
How to reproduce it :
Create a simple FormType, with a collection field, and add entry_options in third parameter of $builder->add()
This array won't be merged in 2.8.1, then change $options['options'] to $options['entry_options'] and it will works.