src/Form/Security/RegistrationType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form\Security;
  3. use App\Entity\Security\User;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  7. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class RegistrationType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options): void
  14.     {
  15.         $builder
  16.             ->add(
  17.                 'username',
  18.                 TextType::class,
  19.                 [
  20.                     'label' => 'Nom d\'utilisateur',
  21.                 ]
  22.             )
  23.             ->add(
  24.                 'email',
  25.                 EmailType::class,
  26.                 [
  27.                     'label' => 'Adresse email',
  28.                 ]
  29.             )
  30.             ->add('password'RepeatedType::class, [
  31.                 'type' => PasswordType::class,
  32.                 'invalid_message' => 'The password fields must match.',
  33.                 'options' => ['attr' => ['class' => 'password-field']],
  34.                 'required' => true,
  35.                 'first_options' => ['label' => 'Mot de passe'],
  36.                 'second_options' => ['label' => 'Répéter le mot de passe'],
  37.             ]);
  38.     }
  39.     public function configureOptions(OptionsResolver $resolver): void
  40.     {
  41.         $resolver->setDefaults([
  42.             'data_class' => User::class,
  43.         ]);
  44.     }
  45. }