PHP code example of toovalu-github / translation-form-bundle
1. Go to this page and download the library: Download toovalu-github/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/ */
toovalu-github / translation-form-bundle example snippets
// Symfony >= 4.0 in bundles.php
// ...
A2lix\AutoFormBundle\A2lixAutoFormBundle::class => ['all' => true],
A2lix\TranslationFormBundle\A2lixTranslationFormBundle::class => ['all' => true],
// ...
// Symfony >= 3.4 in AppKernel::registerBundles()
$bundles = array(
// ...
new A2lix\AutoFormBundle\A2lixAutoFormBundle(),
new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
// ...
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
...
$builder->add('translations', TranslationsType::class);
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
...
$builder->add('translations', TranslationsType::class, [
'locales' => ['en', 'fr', 'es', 'de'], // [1]
'default_locale' => ['en'], // [1]
' // [4]
'locale_options' => [ // [3.b]
'es' => ['label' => 'descripción'], // [4]
'fr' => ['display' => false] // [4]
]
]
],
'excluded_fields' => ['details'], // [2]
'locale_labels' => [ // [5]
'fr' => 'Français',
'en' => 'English',
],
]);
use A2lix\TranslationFormBundle\Form\Type\TranslationsFormsType;
...
$builder->add('translations', TranslationsFormsType::class, [
'locales' => ['en', 'fr', 'es', 'de'], // [1]
'default_locale' => ['en'] // [1]
'
use A2lix\TranslationFormBundle\Form\Type\TranslatedEntityType;
...
$builder->add('medias', TranslatedEntityType::class, [
'class' => 'A2lix\DemoTranslationBundle\Entity\Media', // [1 - Mandatory]
'translation_property' => 'title', // [2 - Mandatory]
'multiple' => true, // [3]
]);