PHP code example of a2lix / translation-form-bundle

1. Go to this page and download the library: Download a2lix/translation-form-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

a2lix / translation-form-bundle example snippets


use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
use Symfony\Component\Form\Extension\Core\Type\FormType;

$builder->add('translations', TranslationsType::class, [
    'translatable_class' => App\Entity\Post::class,
    // Optional:
    // 'locale_labels' => ['en' => 'English', 'fr' => 'Français'],
    // 'theming_granularity' => 'field', // or 'locale_field'
]);

use A2lix\TranslationFormBundle\Form\Type\TranslationsFormsType;

$builder->add('medias', TranslationsFormsType::class, [
    'form_type' => App\Form\CompanyMediaType::class,
    'form_options' => [
        'data_class' => App\Entity\CompanyMediaLocale::class,
    ],
]);

use A2lix\TranslationFormBundle\Form\Type\TranslatedEntityType;

$builder->add('category', TranslatedEntityType::class, [
    'class' => App\Entity\Category::class,
    'translation_property' => 'title',
]);

use A2lix\TranslationFormBundle\Form\Type\TranslationsLocalesSelectorType;

$builder->add('locales', TranslationsLocalesSelectorType::class, [
    // uses the bundle's LocaleProvider to populate choices
]);