a2lixTranslationFormBundle allows you to easily manage translatable fields of your entity with a new form type: 'a2lix_translations'.
You can find documentation and examples on how to make fields translatable on the github page of the bundle.
The bundles stylesheets and javascript files need to be added to the admingenerator templates. In your YourBundleNameBundle/Resources/config/yourPrefix-generator.yml
:
stylesheets:
- bundles/a2lixtranslationform/css/a2lix_translation.css
javascripts:
- /bundles/a2lixtranslationform/js/a2lix_translation.js
In your YourBundleNameBundle/Resources/config/yourPrefix-generator.yml
fields: :
translations:
formType: A2lix\TranslationFormBundle\Form\Type\TranslationsType
Then add to your Edit and New form builders the translations field:
new:
params:
title: Title
display: [title, description, translations]
actions:
save: ~
list: ~
edit:
params:
title: "Edit \"%object%\"|{ %object%: Model.title }|"
display: [title, description, translations]
actions:
save: ~
list: ~
delete: ~
Below an example of an advanced form configuration
fields: :
translations:
formType: a2lix_translations
addFormOptions:
locales: [en, pl]
required: false
fields:
title:
label : name
## OTHER_OPTIONS ##
locale_options:
en:
label : Name
pl:
label : Nazwa
description:
type: textarea
## OTHER_OPTIONS ##
locale_options:
en:
label : Descripcion
pl:
label : Opis
And add to your Edit and New form builders translations field.
new:
params:
title: Title
display: [title, description, translations]
actions:
save: ~
list: ~
edit:
params:
title: "Edit \"%object%\"|{ %object%: Model.title }|"
display: [title, description, translations]
actions:
save: ~
list: ~
delete: ~
generator: admingenerator.generator.doctrine
params:
model: Acme\DemoBundle\Entity\YourModel
namespace_prefix: YourPrefix
bundle_name: DemoBundle
fields:
translations:
formType: a2lix_translations
addFormOptions:
locales: [en, pl]
required: false
fields:
title:
locale_options:
en:
label : Name
pl:
label : Nazwa
description:
locale_options:
en:
label : Descripcion
pl:
label : Opis
stylesheets:
- bundles/a2lixtranslationform/css/a2lix_translation.css
javascripts:
- /bundles/a2lixtranslationform/js/a2lix_translation.js
builders:
list:
params:
title: Title
display: [title]
actions:
new: ~
object_actions:
edit: ~
delete: ~
show: ~
filters:
params:
display: ~
new:
params:
title: New
display: [title, description, translations]
actions:
save: ~
list: ~
edit:
params:
title: "Edit \"%object%\"|{ %object%: YourModel.title }|"
display: [title, description, translations]
actions:
save: ~
list: ~
delete: ~
show:
params:
title: "Show \"%object%\"|{ %object%: YourModel.title }|"
display: [title, description]
actions:
list: ~
new: ~
delete: ~