src/Form/RegistrationType.php line 15

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form;
  4. use App\Entity\User;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  8. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. final class RegistrationType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options): void
  14.     {
  15.         $label_attr = [
  16.             'class' => 'col-12 col-form-label'
  17.         ];
  18.         $builder
  19.             ->add('email'EmailType::class, [
  20.                 'label' => 'email',
  21.                 'translation_domain' => 'messages',
  22.                 'label_attr' => $label_attr
  23.             ])
  24.             ->add('plainPassword'RepeatedType::class, [
  25.                 'type' => PasswordType::class,
  26.                 'first_options' => [
  27.                     'label' => 'account.field.password.first',
  28.                     'label_attr' => $label_attr
  29.                 ],
  30.                 'second_options' => [
  31.                     'label' => 'account.field.password.second',
  32.                     'label_attr' => $label_attr
  33.                 ],
  34.             ]);
  35.     }
  36.     public function configureOptions(OptionsResolver $resolver): void
  37.     {
  38.         $resolver->setDefaults([
  39.             'data_class' => User::class,
  40.             'translation_domain' => 'forms'
  41.         ]);
  42.     }
  43. }