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.

1.1 2014-02-04 15:51 UTC

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

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'.