<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
class PostulerType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('prenom', TextType::class, [
'label' => false,
'required' => true,
'attr' => [
'class' => 'form-control',
'placeholder' => 'Prénom *'
]
])
->add('nom', TextType::class, [
'label' => false,
'required' => true,
'attr' => [
'class' => 'form-control',
'placeholder' => 'Nom *'
]
])
->add('email', EmailType::class, [
'label' => false,
'required' => true,
'attr' => [
'class' => 'form-control',
'placeholder' => 'Adresse e-mail *'
]
])
->add('message', TextareaType::class, [
'label' => false,
'required' => true,
'attr' => [
'class' => 'form-control',
'placeholder' => 'Message',
'rows' => 8
]
])
->add('cv', FileType::class, [
'label' => 'CV * (pdf, png, jpeg)',
'required' => true,
'attr' => [
'class' => 'form-control form-control-sm'
],
'constraints' => [
new File([
'maxSize' => '800k',
'mimeTypes' => [
'image/png',
'image/jpeg',
'application/pdf'
],
'mimeTypesMessage' => 'Le document envoyé n\'est pas valide (PDF ou images .jpg et .png seulement)',
'maxSizeMessage' => 'Le document envoyé est trop gros (800 Ko maxi)'
])
]
])
->add('autredoc', FileType::class, [
'label' => 'Autre document (pdf, png, jpeg)',
'required' => false,
'attr' => [
'class' => 'form-control form-control-sm'
],
'constraints' => [
new File([
'maxSize' => '800k',
'mimeTypes' => [
'image/png',
'image/jpeg',
'application/pdf'
],
'mimeTypesMessage' => 'Le document envoyé n\'est pas valide (PDF ou images .jpg et .png seulement)',
'maxSizeMessage' => 'Le document envoyé est trop gros (800 Ko maxi)'
])
]
])
// ->add('captcha', CaptchaType::class, [
// 'label' => false,
// 'length' => 6,
// 'width' => 200,
// 'height' => 60,
// 'as_url' => true,
// 'reload' => true,
// 'attr' => [
// 'style' => 'width: 200px',
// 'class' => 'form-control',
// ]
// ])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}