Преглед изворни кода

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

feature/symfony6.1
Guillaume пре 2 година
родитељ
комит
d573bc6dd8
2 измењених фајлова са 16 додато и 3 уклоњено
  1. +15
    -3
      Form/Setting/BaseSettingType.php
  2. +1
    -0
      Resources/views/admin/setting/form.html.twig

+ 15
- 3
Form/Setting/BaseSettingType.php Прегледај датотеку

@@ -5,6 +5,7 @@ namespace Lc\SovBundle\Form\Setting;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
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\DateType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
@@ -17,13 +18,16 @@ abstract class BaseSettingType extends AbstractType
{
protected EntityManagerInterface $em;
protected SiteSettingDefinitionInterface $settingDefinition;
protected TranslatorAdmin $translatorAdmin;

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

public function buildFormSetting($label, $form, $settingDefinition, $settingEntity)
@@ -37,7 +41,8 @@ abstract class BaseSettingType extends AbstractType
'text',
TextType::class,
[
'label' => $label
'label' => $label,
'translation_domain' => 'admin',
]
);
} elseif ($settingType == 'textarea') {
@@ -45,7 +50,8 @@ abstract class BaseSettingType extends AbstractType
'text',
TextareaType::class,
[
'label' => $label
'label' => $label,
'translation_domain' => 'admin',
]
);
} elseif ($settingType == 'textarea_advanced') {
@@ -54,6 +60,7 @@ abstract class BaseSettingType extends AbstractType
CKEditorType::class,
[
'label' => $label,
'translation_domain' => 'admin',
'attr' => [
'class' => 'field-text_editor'
]
@@ -65,6 +72,7 @@ abstract class BaseSettingType extends AbstractType
ChoiceType::class,
[
'label' => $label,
'translation_domain' => 'admin',
'expanded' => false,
'multiple' => false,
'placeholder' => false,
@@ -77,6 +85,7 @@ abstract class BaseSettingType extends AbstractType
ChoiceType::class,
[
'label' => $label,
'translation_domain' => 'admin',
'expanded' => true,
'multiple' => false,
'placeholder' => false,
@@ -89,6 +98,7 @@ abstract class BaseSettingType extends AbstractType
DateType::class,
[
'label' => $label,
'translation_domain' => 'admin',
'widget' => 'single_text',
]
);
@@ -98,6 +108,7 @@ abstract class BaseSettingType extends AbstractType
TimeType::class,
[
'label' => $label,
'translation_domain' => 'admin',
'input' => 'datetime',
'widget' => 'single_text',
]
@@ -108,6 +119,7 @@ abstract class BaseSettingType extends AbstractType
FileManagerType::class,
[
'label' => $label,
'translation_domain' => 'admin',
'attr' => [
'type' => $settingType
]

+ 1
- 0
Resources/views/admin/setting/form.html.twig Прегледај датотеку

@@ -11,6 +11,7 @@
{# content #}
{% block content %}
{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %}
{% trans_default_domain 'admin' %}
{{ form_start(form) }}

{# panes #}

Loading…
Откажи
Сачувај