tonydub / form-translation
Translate your doctrine objects easily with a custom field for Symfony2 form component.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 2 249
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.11
- doctrine/collections: v1.1
- symfony/form: >=2.3
- symfony/options-resolver: >=2.3
- symfony/property-access: >=2.3
This package is not auto-updated.
Last update: 2022-02-14 13:10:34 UTC
README
Translate your doctrine objects easily with a custom field for Symfony2 form component.
Requirement
- Symfony >= v2.3
- Your Doctrine objects configured with an i18n strategy of GedmoDoctrineExtension.
Installation
To install the form component simply run composer.phar require "tonydub/form-translation:dev-master"
.
Usage
To use the translatable type you need to register it as a service:
<service id="acme_demo.form.type.translatable_field" class="Tonydub\Component\Form\Extension\Type\TranslatedFieldType"> <argument>acme_demo_translatable_field</argument> <argument>%acme_demo.translations.locale%</argument> <argument>%acme_demo.translations.locales%</argument> <tag name="form.type" alias="acme_demo_translatable_field"/> </service>
You can use then use the type with the form builder:
public function buildForm(FormBuilderInterface $builder, array $options) { $builder //... ->add('title', 'acme_demo_translatable_field', [ 'type' => 'text' ]) ; }
You can find an example of a template fragment twig for translatatble field in file 'Resources/views/Form/div_layout.html.twig'.