<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
class UserFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstname', TextType::class, [
'label' => 'Prénom',
'trim' => true,
'required' => true,
])
->add('lastname', TextType::class, [
'label' => 'Nom',
'trim' => true,
'required' => true,
])
->add('phone', TelType::class, [
'label' => 'Numéro de portable',
'required' => true,
])
->add('email', EmailType::class)
->add('rgpd', CheckboxType::class, [
'constraints' => new IsTrue(),
'label' => 'J\'accepte que les informations portées sur ce formulaire soient obligatoires. Elles font l’objet d’un traitement informatisé destiné à permettre aux candidats de compléter leur dossier de candidature.'
])
->add('save', SubmitType::class, [
'label' => 'S\'inscrire'
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}