Browse Source

[Backend] Paramètres : traduction des labels dans le form

develop
Guillaume 3 years ago
parent
commit
d573bc6dd8
2 changed files with 16 additions and 3 deletions
  1. +15
    -3
      Form/Setting/BaseSettingType.php
  2. +1
    -0
      Resources/views/admin/setting/form.html.twig

+ 15
- 3
Form/Setting/BaseSettingType.php View File

use FOS\CKEditorBundle\Form\Type\CKEditorType; use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Lc\SovBundle\Definition\SiteSettingDefinitionInterface; use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
use Lc\SovBundle\Form\Common\FileManagerType; use Lc\SovBundle\Form\Common\FileManagerType;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
{ {
protected EntityManagerInterface $em; protected EntityManagerInterface $em;
protected SiteSettingDefinitionInterface $settingDefinition; protected SiteSettingDefinitionInterface $settingDefinition;
protected TranslatorAdmin $translatorAdmin;


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
SiteSettingDefinitionInterface $settingDefinition
SiteSettingDefinitionInterface $settingDefinition,
TranslatorAdmin $translatorAdmin
) { ) {
$this->em = $entityManager; $this->em = $entityManager;
$this->settingDefinition = $settingDefinition; $this->settingDefinition = $settingDefinition;
$this->translatorAdmin = $translatorAdmin;
} }


public function buildFormSetting($label, $form, $settingDefinition, $settingEntity) public function buildFormSetting($label, $form, $settingDefinition, $settingEntity)
'text', 'text',
TextType::class, TextType::class,
[ [
'label' => $label
'label' => $label,
'translation_domain' => 'admin',
] ]
); );
} elseif ($settingType == 'textarea') { } elseif ($settingType == 'textarea') {
'text', 'text',
TextareaType::class, TextareaType::class,
[ [
'label' => $label
'label' => $label,
'translation_domain' => 'admin',
] ]
); );
} elseif ($settingType == 'textarea_advanced') { } elseif ($settingType == 'textarea_advanced') {
CKEditorType::class, CKEditorType::class,
[ [
'label' => $label, 'label' => $label,
'translation_domain' => 'admin',
'attr' => [ 'attr' => [
'class' => 'field-text_editor' 'class' => 'field-text_editor'
] ]
ChoiceType::class, ChoiceType::class,
[ [
'label' => $label, 'label' => $label,
'translation_domain' => 'admin',
'expanded' => false, 'expanded' => false,
'multiple' => false, 'multiple' => false,
'placeholder' => false, 'placeholder' => false,
ChoiceType::class, ChoiceType::class,
[ [
'label' => $label, 'label' => $label,
'translation_domain' => 'admin',
'expanded' => true, 'expanded' => true,
'multiple' => false, 'multiple' => false,
'placeholder' => false, 'placeholder' => false,
DateType::class, DateType::class,
[ [
'label' => $label, 'label' => $label,
'translation_domain' => 'admin',
'widget' => 'single_text', 'widget' => 'single_text',
] ]
); );
TimeType::class, TimeType::class,
[ [
'label' => $label, 'label' => $label,
'translation_domain' => 'admin',
'input' => 'datetime', 'input' => 'datetime',
'widget' => 'single_text', 'widget' => 'single_text',
] ]
FileManagerType::class, FileManagerType::class,
[ [
'label' => $label, 'label' => $label,
'translation_domain' => 'admin',
'attr' => [ 'attr' => [
'type' => $settingType 'type' => $settingType
] ]

+ 1
- 0
Resources/views/admin/setting/form.html.twig View File

{# content #} {# content #}
{% block content %} {% block content %}
{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %} {% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %}
{% trans_default_domain 'admin' %}
{{ form_start(form) }} {{ form_start(form) }}


{# panes #} {# panes #}

Loading…
Cancel
Save