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

Can't add translation_domain to form field #720

Open
fadoe opened this issue Jan 13, 2014 · 8 comments
Open

Can't add translation_domain to form field #720

fadoe opened this issue Jan 13, 2014 · 8 comments

Comments

@fadoe
Copy link
Contributor

fadoe commented Jan 13, 2014

I try to add the translation domain to a form field:

params:
    fields:
        moduleName:
            formType: entity
            addFormOptions:
                class: MyBundle:MyEntity
                property: myProperty
                translation_domain: MyTranslationDomain

But the generated form type add always 'translation_domain' => 'Admin'. Is this a bug or is that intentional?

@ioleo
Copy link
Member

ioleo commented Jan 13, 2014

You should set it in i18n_catalog, eg:

params:
    model:              Acme\DemoBundle\Entity\Note
    namespace_prefix:   Acme
    bundle_name:        DemoBundle
    i18n_catalog:       DemoNote

@fadoe
Copy link
Contributor Author

fadoe commented Jan 14, 2014

@loostro That's right, but i18n_catalog is for the complete form. In my case I want the translation domain for only one field. In the documentation from Symfony it's possible.

@ioleo
Copy link
Member

ioleo commented Jan 14, 2014

@fadoe i see your need. to answer your question: it was intentional. We assumed that if i18n_catalog is not specified, use Admin catalog. But it should be possible to overwrite that.. why it is not? Probably some bad code.

@ioleo
Copy link
Member

ioleo commented Jan 14, 2014

@fadoe Eg. see here Resources/templates/CommonAdmin/title.php.twig#L4 - the "translation_domain" is not even used. It's either i18n_catalog or default.

Come to think of it, at the time Admingenerator was created (symfony 2.0 times) I don't think all forms had "translation_domain" inherited property. I think they introduced that later, sometime between 2.1 and 2.2. And that might be why this code looks like this.

@fadoe
Copy link
Contributor Author

fadoe commented Jan 14, 2014

@loostro I see. The question is: Does it make sense to add this feature to the generator.yml? I see no BC break and the admin generator uses Symfony 2.2 and up.

@ioleo
Copy link
Member

ioleo commented Jan 14, 2014

@fadoe if you have time to fix all the |default("Admin") in templates and replace them to use translation_domain (which, by default, should be "Admin", unless i18n_catalog is defined, then it should be set to i18n_catalog value) I'll gladly merge that

@fadoe
Copy link
Contributor Author

fadoe commented Jan 14, 2014

@loostro I note this issue. I will see when I have a few minutes time ;-)

@sescandell
Copy link
Member

@fadoe Waiting for a fix, you can use the getFormOptions function in your base XXXType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants