src/Form/RegistrationFormType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Structure;
  4. use App\Entity\User;
  5. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  8. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  9. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. class RegistrationFormType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $builder
  18.             ->add('role'ChoiceType::class, [
  19.                 'label' => false,
  20.                 'mapped' => false,
  21.                 'choices'  => [
  22.                     'Candidat' => 'ROLE_CANDIDAT',
  23.                     'Admin Structure' => 'ROLE_ADMIN_STRUCTURE',
  24.                 ],
  25.             ])
  26.             ->add('email'EmailType::class, [
  27.                 'label' => false,
  28.                 'attr' => ['placeholder'=> 'Adresse mail'],
  29.             ])
  30.             ->add('password'PasswordType::class, [
  31.                 'label' => false,
  32.                 'attr' => ['placeholder'=> 'Mot de passe']
  33.             ])
  34.             ->add('confirmPassword'PasswordType::class, [
  35.                 'label' => false,
  36.                 'attr' => ['placeholder'=> 'Confirmez votre mot de passe']
  37.             ])
  38.             ->add('firstName'TextType::class, [
  39.                 'label' => false,
  40.                 'required' => false,
  41.                 'attr' => ['placeholder'=> 'PrĂ©nom']
  42.             ])
  43.             ->add('lastName'TextType::class, [
  44.                 'label' => false,
  45.                 'required' => false,
  46.                 'attr' => ['placeholder'=> 'Nom']
  47.             ])
  48.             ->add('nomStructure'EntityType::class, [
  49.                 'class' => Structure::class,
  50.                 'choice_label' => 'nomStructure',
  51.                 'label' => false,
  52.                 'mapped' => false,
  53.     ]);
  54.     }
  55.     public function configureOptions(OptionsResolver $resolver): void
  56.     {
  57.         $resolver->setDefaults([
  58.             'data_class' => User::class,
  59.             'attr' => [
  60.                 'novalidate' => 'novalidate'
  61.             ],
  62.         ]);
  63.     }
  64. }