Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Form] [ChoiceType] Prefer placeholder to empty_value#16886
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
4271ab1 to4dec2c8CompareUse assertSame instead of assertEquals in some ChoiceTypeTest methodswhich test placeholder/empty_value options, because the tested valuemay be any number of "falsey" values.
Add an extra condition to the use of the value of the empty_value optionas the placeholder: the value of the placeholder option must be null oran empty string (i.e. not explicitly set).Test the effects of setting both placeholder and empty_value.
| 'An unset empty_value is automaticaly made an empty string in a non-required field (but null is expected here) [maintains BC]' =>array(false,false,false,null,null,''), | ||
| 'An empty string empty_value is used if placeholder is not set [maintains BC]' =>array(false,false,false,null,'',''), | ||
| 'A non-empty string empty_value is used if placeholder is not set [maintains BC]' =>array(false,false,false,null,'bar','bar'), | ||
| 'A placeholder is not used if it is an empty string and empty_value is set to false [mainatins BC]' =>array(false,false,false,'',false,null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
typo "maintains"
HeahDude commentedFeb 14, 2016
👍 except your last test being very difficult to read. Perhaps you could organise lines by BC first, then by expanded or multiple. |
xabbuh commentedFeb 18, 2016
The fix looks good, but do we really need so many test fixtures? Can we reduce them to the bare minimum? |
boite commentedFeb 28, 2016
@xabbuh the (admittedly extensive) test data were invaluable in that they revealed when the fix was finally correct after a number of failed attempts. Surely, one datum for each possible permutationis the bare minimum. |
| $placeholder, | ||
| $emptyValue, | ||
| $viewValue | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should be moved on one line
fabpot commentedFeb 29, 2016
👍 |
webmozart commentedMar 2, 2016
👍 |
fabpot commentedMar 2, 2016
Thank you@boite. |
This PR was squashed before being merged into the 2.7 branch (closes#16886).Discussion----------[Form] [ChoiceType] Prefer placeholder to empty_value| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#16885| License | MIT| Doc PR | -Prefer an explicitly set `placeholder` option (i.e. `false` or a non-emptystring) to an `empty_value` option when both are set.The fix is to change the behaviour in the placeholder normalizer inChoiceType::configureOptions so that the value of the `empty_value` option isused for placeholder only when the value of `placeholder` is null or an emptystring.Commits-------a4d4c8a [Form] [ChoiceType] Prefer placeholder to empty_value
| 'A placeholder is not used if it is explicitly set to false' =>array(false,false,false,false,null,null), | ||
| 'A placeholder is not used if it is explicitly set to false' =>array(false,false,false,false,'',null), | ||
| 'A placeholder is not used if it is explicitly set to false' =>array(false,false,false,false,'bar',null), | ||
| 'A placeholder is not used if empty_value is set to false [maintains BC]' =>array(false,false,false,null,false,null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
All those tests may not run because some keys are overridden...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
indeed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm on it
HeahDude commentedMar 2, 2016
Here's the actual report : |
boite commentedMar 2, 2016
Damn it! Will you let me sort this out? I'll do a better job of naming the data keys for readability (and uniqueness). |
HeahDude commentedMar 2, 2016
I fixed it, but I still can hold the PR. What do I do ? |
HeahDude commentedMar 2, 2016
This PR was merged into the 2.7 branch.Discussion----------[Form] fix tests added by#16886| Q | A| ------------- | ---| Branch | 2.7+| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#16886| License | MIT| Doc PR | -Commits-------bd22c86 minor [Form] fix tests added by#16886
* 2.7: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added by#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
* 2.8: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added by#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
* 3.0: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added by#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
* 2.7: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added bysymfony#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
* 2.8: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added bysymfony#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
* 3.0: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added bysymfony#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
Prefer an explicitly set
placeholderoption (i.e.falseor a non-emptystring) to an
empty_valueoption when both are set.The fix is to change the behaviour in the placeholder normalizer in
ChoiceType::configureOptions so that the value of the
empty_valueoption isused for placeholder only when the value of
placeholderis null or an emptystring.