<?php
namespace App\Form;
use App\Entity\Structure;
use App\Entity\User;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('role', ChoiceType::class, [
'label' => false,
'mapped' => false,
'choices' => [
'Candidat' => 'ROLE_CANDIDAT',
'Admin Structure' => 'ROLE_ADMIN_STRUCTURE',
],
])
->add('email', EmailType::class, [
'label' => false,
'attr' => ['placeholder'=> 'Adresse mail'],
])
->add('password', PasswordType::class, [
'label' => false,
'attr' => ['placeholder'=> 'Mot de passe']
])
->add('confirmPassword', PasswordType::class, [
'label' => false,
'attr' => ['placeholder'=> 'Confirmez votre mot de passe']
])
->add('firstName', TextType::class, [
'label' => false,
'required' => false,
'attr' => ['placeholder'=> 'Prénom']
])
->add('lastName', TextType::class, [
'label' => false,
'required' => false,
'attr' => ['placeholder'=> 'Nom']
])
->add('nomStructure', EntityType::class, [
'class' => Structure::class,
'choice_label' => 'nomStructure',
'label' => false,
'mapped' => false,
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
'attr' => [
'novalidate' => 'novalidate'
],
]);
}
}