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] Cast choices value callback result to string #49009

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

Matth--
Copy link
Contributor

@Matth-- Matth-- commented Jan 17, 2023

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #42394
License MIT
Doc PR X

When using "multiple" and "choice_value" callback on a CollectionType or EntityType, the result for the callback needs to be a string. By forcing a string cast, default values will show up in the form view.

@Matth--
Copy link
Contributor Author

Matth-- commented Jan 17, 2023

Not sure what to do about the failing test as the DoctrineChoiceLoader extends from the AbstractLoader located in the Form component.

@stof
Copy link
Member

stof commented Jan 17, 2023

high-deps will be fixed once the PR is merged up. But low-deps requires a change in the lowest bound of the constraint in the doctrine-bridge

@Matth--
Copy link
Contributor Author

Matth-- commented Jan 17, 2023

@stof I could also remove the test case as it does pretty much the same thing as the one in the Form component. I added it in the first case because I had issues with the EntityType. WDYT?

@Matth--
Copy link
Contributor Author

Matth-- commented Mar 27, 2023

Is there anything I should change for this PR? Or should we find a different solution to this.

Sorry for the tag
@xabbuh

If using "multiple" and "choice_value" on a CollectionType or EntityType, the result for the callback needs to be a string. By forcing a string cast, default values will show up in the form view.
@nicolas-grekas
Copy link
Member

Thank you @Matth--.

@nicolas-grekas nicolas-grekas merged commit 887c7b0 into symfony:5.4 Apr 17, 2023
6 of 9 checks passed
@Matth-- Matth-- deleted the fix/values-for-choices branch April 21, 2023 11:28
This was referenced Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants