8000 [Form][2.8.1] entry_options are not passed to sub forms · Issue #17361 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form][2.8.1] entry_options are not passed to sub forms #17361

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
steevanb opened this issue Jan 14, 2016 · 1 comment
Closed

[Form][2.8.1] entry_options are not passed to sub forms #17361

steevanb opened this issue Jan 14, 2016 · 1 comment
Labels

Comments

@steevanb
Copy link

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.

@xabbuh
Copy link
Member
xabbuh commented Jan 14, 2016

This is already fixed by #17162 and will be part of the 2.8.2 release.

@xabbuh xabbuh closed this as completed Jan 14, 2016
@xabbuh xabbuh added the Form label Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
0