-
Notifications
You must be signed in to change notification settings - Fork 293
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
Extracting choices not keys from forms #332
Comments
Since Symfony 2.7 (I think) Symfony changed meaning of the keys and values. This is something we really need to look into. |
Let me know if i can help you any further. |
Yes, please. Do you have any suggestions how to solve it? |
I narrowed it down to Line 123 within FormExtractor.php. We could also achieve it by passing a 3rd parameter to parseItem() But I think that's unnecessary unless you wanna make the bundle running for both versions. And chaning more lines within the parseItem function. Using annotations would confuse most ppl. My solution would be:
For a symfony 3.0 solution we only need 3) thx |
Stumpled upon the same problem (I think) in a project with lots of forms with lots of choices in 2.7.11 with choices_as_values = true. it doesn't add them to the translation files and sometimes exits with the above mentioned error. Since this project will be moved to 3.1 soon, I cannot switch back to the old behaviour. Error only happens if the file already exists. If I delete the file it will get created without an error (but of course without the choice-translations) |
Hi @ScherlOMatic and thank for reporting this issue. This problem affects every version >= 2.7 if we try to avoid depreciations message so i'd suggest to release a small patch for this one before the symfony 3 version. I'm also looking into this right now. |
Closed by #334 |
Expected behavior
The FormExtractor.php file might have an issue with handling of choicetype fields. Especially with 'choices'. It seems like the extractor is trying to translate the values instead of the keys.
The case is described in here https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md #choices_as_values
Actual behavior
After reexecuting the translation:extract command I get this message:
[JMS\TranslationBundle\Exception\RuntimeException]
You can only merge messages with the same id. Expected id "0", but got "0".
The id "0" but got "0" sounds confusing but I'm positive that this is the key of the choice field. After deleting the "0" item, i got the next one of my choices.
Steps to reproduce
Create a form with one ChoiceType field, set some values and try to extract messages twice.
I think the parseItem() function needs to be changed.
The text was updated successfully, but these errors were encountered: