uerka / translation-form-bundle
Provides widget to manage entity's translations
Installs: 425
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.1.3
- knplabs/doctrine-behaviors: ~1.5
- symfony/config: ~3.4|~4.0
- symfony/dependency-injection: ^3.0|^4.0
- symfony/form: ^3.0|^4.0
This package is not auto-updated.
Last update: 2025-04-27 08:08:12 UTC
README
Simplified version of https://github.com/a2lix/TranslationFormBundle. Supports only https://github.com/KnpLabs/DoctrineBehaviors. Supports symfony4
##Installation
composer require uerka/translation-form-bundle
Add to bundles:
Symfony4 - bundles.php
return [ ... Uerka\TranslationFormBundle\UerkaTranslationFormBundle::class => ['all' => true],
Symfony3 - AppKernel.php
public function registerBundles() { $bundles = [ ... new Uerka\TranslationFormBundle\UerkaTranslationFormBundle(), }
Configuration
uerka_translation_form: locales: ["ru", "en"]
Add theme to twig settings:
twig: ... form_themes: ... - '@UerkaTranslationForm/form/fields.html.twig'
Using form
... use Uerka\TranslationFormBundle\Form\Type\TranslationsType; class ExampleFormType extends AbstractType { /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('translations', TranslationsType::class, [ 'locales' => ['ru', 'en', 'fr'], // optional, defaults to bundle's config 'required_locales' => ['en'], // optional, defaults to bundle's config (equals to locale option) 'fields' => [ 'name' => [ 'widget_class' => TextType::class, // optional, default TextType::class 'options' => [ // will be passed to field's options 'label' => 'form.label.name', ], ], 'shortDescription' => [ 'widget_class' => TextareaType::class, 'options' => [ 'label' => 'form.label.short_description', 'required' => false, ] ], ], ]); ... } ... }