src/Form/FamilyMemberTypeBasic.php line 16
<?php
namespace App\Form;
use App\Entity\FamilyMember;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
class FamilyMemberTypeBasic extends AbstractType
{
public function __construct(private TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
// ->add('type', ChoiceType::class, [
// 'label' => 'Type ',
// 'required' => true,
// 'attr' => [
// 'class' => 'form-control select2-modal'
// ],
// 'help' => '',
// 'choices' => [
// $this->translator->trans('Father') => 'Father',
// $this->translator->trans('Mother') => 'Mother',
// $this->translator->trans('Brother') => 'Brother',
// $this->translator->trans('Sister') => 'Sister',
// $this->translator->trans('Grand-Father') => 'Grand-Father',
// $this->translator->trans('Grand-Mother') => 'Grand-Mother',
// $this->translator->trans('Uncle') => 'Uncle',
// $this->translator->trans('Aunt') => 'Aunt'
// ]
// ])
->add('first_name', TextType::class, [
'label' => $this->translator->trans('Prénom'),
'required' => true,
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'help' => ''
])
->add('last_name', TextType::class, [
'label' => $this->translator->trans('Nom'),
'required' => true,
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'help' => ''
])
->add('email', EmailType::class, [
'invalid_message' => $this->translator->trans('Email non valid'),
'required' => false,
'label' => 'Email',
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'help' => ''
])
->add('phone', TextType::class, [
'label' => $this->translator->trans('Téléphone'),
'required' => false,
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'help' => ''
])
->add('mobile', TextType::class, [
'label' => $this->translator->trans('Mobile'),
'required' => false,
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'help' => ''
])
->add('job', TextType::class, [
'label' => $this->translator->trans('Emploi'),
'required' => false,
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'help' => ''
])
->add('photo', FileType::class, [
'attr' => [
'class' => 'form-control',
'placeholder' => ''
],
'label' => $this->translator->trans('Photo d\'identité'),
'mapped' => false,
'required' => false,
'constraints' => [
new File([
'maxSize' => '2048k',
'mimeTypes' => [
'image/*',
],
'mimeTypesMessage' => $this->translator->trans('Veuillez télécharger une image valide'),
])
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => FamilyMember::class,
]);
}
}