Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Closed
boite wants to merge4 commits intosymfony:2.7fromboite:ticket_16885

Conversation

@boite
Copy link
Contributor

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#16885
LicenseMIT
Doc PR-

Prefer an explicitly setplaceholder option (i.e.false or a non-empty
string) to anempty_value option when both are set.

The fix is to change the behaviour in the placeholder normalizer in
ChoiceType::configureOptions so that the value of theempty_value option is
used for placeholder only when the value ofplaceholder is null or an empty
string.

@boiteboiteforce-pushed theticket_16885 branch 4 times, most recently from4271ab1 to4dec2c8CompareDecember 14, 2015 10:24
Use 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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

typo "maintains"

@HeahDude
Copy link
Contributor

👍 except your last test being very difficult to read.

Perhaps you could organise lines by BC first, then by expanded or multiple.
Rephrasing might help like :
"If placeholder is null", "If placeholder is false and empty_value is empty" ...

@xabbuh
Copy link
Member

The fix looks good, but do we really need so many test fixtures? Can we reduce them to the bare minimum?

@boite
Copy link
ContributorAuthor

@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
) {
Copy link
Member

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
Copy link
Member

👍

@webmozart
Copy link
Contributor

👍

@fabpot
Copy link
Member

Thank you@boite.

fabpot added a commit that referenced this pull requestMar 2, 2016
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
@fabpotfabpot closed thisMar 2, 2016
'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),
Copy link
Contributor

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...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

indeed

Copy link
Contributor

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
Copy link
Contributor

Here's the actual report :

There were 8 failures:1) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "An empty string empty_value is converted to "None" in an expanded single choice field when expanded and required [maintains BC]" (false, true, true, null, '', 'None')Failed asserting that null is identical to 'None'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19132) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "A non-empty string empty_value is used if placeholder is not set when expanded and required [maintains BC]" (false, true, true, null, 'bar', 'bar')Failed asserting that null is identical to 'bar'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19133) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "An empty string empty_value is converted to "None" in an expanded single choice field when required [maintains BC]" (false, true, true, '', '', 'None')Failed asserting that null is identical to 'None'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19134) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "A non-empty string empty_value is used if placeholder is an empty string when expanded and required [maintains BC]" (false, true, true, '', 'bar', 'bar')Failed asserting that null is identical to 'bar'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19135) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "A non-empty string placeholder takes precedence over an empty_value set to false when expanded and required" (false, true, true, 'foo', false, 'foo')Failed asserting that null is identical to 'foo'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19136) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "A non-empty string placeholder takes precedence over a not set empty_value when expanded and required" (false, true, true, 'foo', null, 'foo')Failed asserting that null is identical to 'foo'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19137) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "A non-empty string placeholder takes precedence over an empty string empty_value when expanded and required" (false, true, true, 'foo', '', 'foo')Failed asserting that null is identical to 'foo'./Users/Heah/Sites/dev/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:19138) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testPlaceholderOptionWithEmptyValueOption with data set "A non-empty string placeholder takes precedence over a non-empty string empty_value when expanded and required" (false, true, true, 'foo', 'bar', 'foo')Failed asserting that null is identical to 'foo'.

@boite
Copy link
ContributorAuthor

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
Copy link
Contributor

I fixed it, but I still can hold the PR. What do I do ?

HeahDude added a commit to HeahDude/symfony that referenced this pull requestMar 2, 2016
@HeahDude
Copy link
Contributor

@boite, see#17988, feel free to send a PR that better suits you and I'll close this one.

fabpot added a commit that referenced this pull requestMar 3, 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
fabpot added a commit that referenced this pull requestMar 4, 2016
* 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
fabpot added a commit that referenced this pull requestMar 4, 2016
* 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
fabpot added a commit that referenced this pull requestMar 4, 2016
* 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
This was referencedMar 25, 2016
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull requestMar 25, 2018
* 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
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull requestMar 25, 2018
* 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
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull requestMar 25, 2018
* 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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@boite@HeahDude@xabbuh@fabpot@webmozart@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp