mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Use EnumType in form instead of ChoiceType for field genderTranslation
This commit is contained in:
parent
0ba93ec7c6
commit
789c977aba
@ -8,6 +8,7 @@ use Chill\MainBundle\Entity\GenderIconEnum;
|
|||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@ -21,18 +22,25 @@ class GenderType extends AbstractType
|
|||||||
->add('label', TranslatableStringFormType::class, [
|
->add('label', TranslatableStringFormType::class, [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
])
|
])
|
||||||
|
/* ->add('icon', EnumType::class, [
|
||||||
|
'class' => GenderIconEnum::class,
|
||||||
|
'label_html' => true,
|
||||||
|
'expanded' => false,
|
||||||
|
'mapped' => true,
|
||||||
|
])*/
|
||||||
->add('icon', ChoiceType::class, [
|
->add('icon', ChoiceType::class, [
|
||||||
'choices' => GenderIconEnum::cases(),
|
'choices' => GenderIconEnum::cases(),
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'mapped' => true,
|
'mapped' => true,
|
||||||
'label' => 'Select Gender Icon',
|
'choice_label' => fn(GenderIconEnum $enum) => '<i class="' . strtolower($enum->value) . '"></i>',
|
||||||
|
'choice_value' => fn(?GenderIconEnum $enum) => $enum ? $enum->value : null,
|
||||||
|
'label' => 'gender.admin.Select Gender Icon',
|
||||||
|
'label_html' => true,
|
||||||
])
|
])
|
||||||
->add('genderTranslation', ChoiceType::class, [
|
->add('genderTranslation', EnumType::class, [
|
||||||
'choices' => GenderEnum::cases(),
|
'class' => GenderEnum::class,
|
||||||
'choice_label' => fn(GenderEnum $enum) => ucfirst(strtolower($enum->name)),
|
'label' => 'gender.admin.Select Gender Translation',
|
||||||
'choice_value' => fn(?GenderEnum $enum) => $enum ? $enum->value : null,
|
|
||||||
'data_class' => null,
|
|
||||||
])
|
])
|
||||||
->add('active', ChoiceType::class, [
|
->add('active', ChoiceType::class, [
|
||||||
'choices' => [
|
'choices' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user