-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Doctrine][Bridge] EntityType : default choices value #2504
Conversation
…or not false value. By this way, it is possible to retrieve an empty result **array()**.
This is valid, however as a fix i am not sure if an is_array() check would be better here, since "null" now fails for this case as well. |
First, it would be useful if you went ahead & created a test case (that would fail on Second, I would assume the behavior would be the following because of semantics:
|
It is my first PR and I was quite lost regarding PR. Thanks for advises. It makes sense. |
- is_array() used to test if choices are user-defined.
We'll have to get some feedback from @beberlei. I'm usually hesitant to encourage extra work, since sometimes simple improvements go through a lot of architecture discussions. (Especially considering the required change to |
Some coments: |
@beberlei: Can you comment on this PR? |
+1 |
@fabpot You can merge this PR, its good this way. |
@RapotOR: Can you squash your commits before I merge this PR? Thanks. |
it also need to be rebased on top of master as github says it conflicts |
I've squashed the commits and github created a new PR #2868. I close this one. |
Commits ------- 4d64d90 Allow empty result; change default *choices* value to **null** instead of **array()**. - added *testEmptyChoicesAreManaged* test - `null` as default value for choices. - is_array() used to test if choices are user-defined. - `null` as default value in __construct too. - `null` as default value for choices in EntityType. Discussion ---------- [Doctrine][Bridge] EntityType: Allow empty result; default `choices` value changed to null Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes References the following tickets: #2504 - added *testEmptyChoicesAreManaged* test - `null` as default value for choices. - is_array() used to test if choices are user-defined. - `null` as default value in __construct too. - `null` as default value for choices in EntityType. I squashed commits from PR #2504 as requested.
If the choices property is equal to array(), the EntityChoiceList don't use empty choices and try query_builder or findAll.
We should use false as default instead of array() to be able to have an empty list if a custom filter gives an empty result. With array() as default, the EntityType populates choices with findAll even if our result was empty; and it is not expected.
(PR created instead of #2500 to pull it into 2.0 branch)