Skip to content

Improved the example about Choice constraint callback #10679

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

Merged
merged 1 commit into from
Nov 16, 2018

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz commented Nov 15, 2018

I don't know if this is 100% correct, but in a real Symfony project, the callback without the FQCN didn't work (at least when using the PHP annotations).

@kunicmarko20
Copy link
Contributor

Maybe it works only if they are in the same namespace?

@@ -222,7 +222,7 @@ you can pass the class name and the method as an array.
class Author
{
/**
* @Assert\Choice(callback={"Util", "getGenres"})
* @Assert\Choice(callback={"AppBundle\Entity\Genre", "getGenres"})
Copy link
Contributor

@kunicmarko20 kunicmarko20 Nov 15, 2018

Choose a reason for hiding this comment

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

This can also be Genre::class but I guess it is more clear this way

Copy link
Contributor

@kunicmarko20 kunicmarko20 left a comment

Choose a reason for hiding this comment

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

https://3v4l.org/gY4gN even if it is in the same namespace it still returns false, this seems like a valid change.

@javiereguiluz
Copy link
Member Author

Marko, thanks a lot for reviewing this and for creating the sample code!

@javiereguiluz javiereguiluz merged commit dece243 into symfony:2.8 Nov 16, 2018
javiereguiluz added a commit that referenced this pull request Nov 16, 2018
…aviereguiluz)

This PR was merged into the 2.8 branch.

Discussion
----------

Improved the example about Choice constraint callback

I don't know if this is 100% correct, but in a real Symfony project, the `callback` without the FQCN didn't work (at least when using the PHP annotations).

Commits
-------

dece243 Improved the example about Choice constraint callback
@xabbuh
Copy link
Member

xabbuh commented Nov 19, 2018

👍

@xabbuh
Copy link
Member

xabbuh commented Nov 19, 2018

I think someone took Util just as an example for any FQCN (which is surely not very obvious when reading the docs).

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.

4 participants