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] Reverted string expectation in ChoiceToValueTransformer#18462

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
walczakmac wants to merge1 commit intosymfony:3.0fromwalczakmac:choicetype-string-fix
Closed

[Form] Reverted string expectation in ChoiceToValueTransformer#18462

walczakmac wants to merge1 commit intosymfony:3.0fromwalczakmac:choicetype-string-fix

Conversation

@walczakmac
Copy link

QA
Branch?3.0
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#18461
LicenseMIT
Doc PRn/a

$this->assertSame($outWithNull,$this->transformerWithNull->reverseTransform($inWithNull));
}

publicfunctionreverseTransformExpectsStringOrNullProvider()
Copy link
Contributor

Choose a reason for hiding this comment

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

You also need to rename those functions with*ExpectsScalarOrNull*.

@HeahDude
Copy link
Contributor

See also#17760 (comment) for a reason to not revert that change.

@HeahDude
Copy link
Contributor

Another reason would be consistency with theChoicesToValuesTransformer which implies the following:

$builder->add('emailNotificationsEnabled', ChoiceType::class, ['required' =>false,'multiple' =>false,'choices'  => [0,1],'empty_data' =>1,// works If we revert by merging this PR]);$builder->add('emailNotificationsEnabled', ChoiceType::class, ['required' =>false,'multiple' =>true,// ChoicesToValuesTransformer will be called'choices'  => [0,1],'empty_data' =>array(1),// won't work it expects array of strings array('1')]);

@HeahDude
Copy link
Contributor

Andempty_data => false won't work either with the revert. Still need to pass'0'.

@HeahDude
Copy link
Contributor

Also consider that:

$builder->add('emailNotificationsEnabled', ChoiceType::class, ['required' =>false,'multiple' =>false,'choices'  => [null,0,1],'empty_data' =>1,// will match 0, needs the key '2' to match 1]);

@HeahDude
Copy link
Contributor

@HeahDude
Copy link
Contributor

Note that if accepted, this PR should be merged in 2.7.

@walczakmac
Copy link
Author

Now I see that there are too many cons when reverting it to previous state, and it will be much easier if I use strings there instead of integers. I'll just close the PR and the ticket, also thanks for your help@HeahDude.

@HeahDude
Copy link
Contributor

No worry ;) Thank you for the report.

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.

3 participants

@walczakmac@HeahDude@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp