Skip to content
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

[Form][BC-break] choice-list option breaks rendering of the form #15037

Closed
aledeg opened this issue Jun 19, 2015 · 6 comments
Closed

[Form][BC-break] choice-list option breaks rendering of the form #15037

aledeg opened this issue Jun 19, 2015 · 6 comments

Comments

@aledeg
Copy link

aledeg commented Jun 19, 2015

I created a custom type which uses a custom LazyChoiceList object to load my choices. It was working from SF2.4 to SF2.6.
With SF2.7, I got the following error message:

Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\ChoiceList\Factory \DefaultChoiceListFactory::Symfony\Component\Form\ChoiceList\Factory{closure}() must be an instance of Symfony\Component\Form\Extension\Core\View\ChoiceView, array given

After investigation, the problem comes from the createView method in Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory.php.

As I am using deprecated code in 2.7, I use the first part of the code. Unfortunately, the closure can not work since it accepts only LegacyChoiceView objects and it receives arrays.

If one change the hint to array, the closure code won't work since an object is needed.
If one change the return type of the method getRemainingView from array to LegacyChoiceView, the array_map won't work since its second parameter must be an array.

I read 2.8 code and this code is still there.

@webmozart webmozart added the Form label Jun 22, 2015
@webmozart
Copy link
Contributor

Hi @aledeg, thank you for taking the time to report this problem! Could you please upload a fork of symfony-standard that reproduces your problem?

@webmozart webmozart added the Bug label Jun 22, 2015
@aledeg
Copy link
Author

aledeg commented Jun 22, 2015

Hi @webmozart, I don't understand what you want me to upload. Could you give more information?

@webmozart
Copy link
Contributor

Sure! Go to https://github.com/symfony/symfony-standard and click "Fork" on the top right to fork the Symfony Standard Edition to your own account (see https://help.github.com/articles/fork-a-repo/ for help). Reproduce the bug in this project, commit the code and push the branch to your fork. Then send me a link to your fork and the name of the branch. I will download the branch and should be able to see your bug exactly like you do. :)

Better now?

@aledeg
Copy link
Author

aledeg commented Jun 22, 2015

Thanks for the explanation.

@aledeg
Copy link
Author

aledeg commented Jun 22, 2015

@webmozart Here is the link to my fork and the name of my branch is form-exception

@trsteel88
Copy link
Contributor

+1 - having the same issue. Symfony 2.7.1

fabpot added a commit that referenced this issue Aug 22, 2015
This PR was squashed before being merged into the 2.7 branch (closes #15546).

Discussion
----------

[Form] fixed BC-break on grouped choice lists

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15037
| License       | MIT
| Doc PR        |

Commits
-------

12a7dd1 [Form] fixed BC-break on grouped choice lists
@fabpot fabpot closed this as completed Aug 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants