-
Notifications
You must be signed in to change notification settings - Fork 33
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
SymfonyForm: ChoiceType issue #72
Comments
Thank you for a very well explained issue. I will make sure we fix the rest. |
I've added a PR for this issue now. Having this in the form type: 'choices' => $this->entityManager->getRepository(Market::class)->findBy([], ['name' => 'asc']), .... should generate an error. You should use |
I confirm that when you use entities from DB in general there is no need to do any translations as shown in the extract of ChoceType settings in the opening message (in case translation is needed custom choice_label callable would probably be used for that matter) |
When you use ChoiceType in Symfony with options you don't want to translate, you can use a setting 'choice_translation_domain' => false which prevents translation. You can also use choices as a result of a method and provide callbacks for extracting "choice_label" and "choice_value". It seems that something works incorrectly in given example.
ChoiceType configuration
Error result (pointing to the 'choices' configuration line):
This should prevent any review of "choices". Despite that there is an error, that choices should be an array (in this case it is result of EntityRepostory:find) what is an additional issue I think.
I am not sure if there is one or two issues here (one: not handling 'choice_translation_domain' correctly and/or not handling calling other functions as a source of choices)
I can of course hack that by adding "@ignore" annotation but it is a bit inconvenient (as we have now 2 places which defines same behavior - options translated or not - and it poses a risk that one thing changed might create configuration inconsistency)
If you need any additional details don't hesitate to ask me.
The text was updated successfully, but these errors were encountered: