src/Form/RegistrationFormType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\User;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. // use Symfony\Component\Validator\Constraints\IsTrue;
  10. // use Symfony\Component\Validator\Constraints\Length;
  11. use Symfony\Component\Validator\Constraints\NotBlank;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. class RegistrationFormType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('pseudo'TextType::class, [
  20.                 'attr' => [
  21.                     'class' => 'text-center form-control-lg',
  22.                     'placeholder' => 'username',
  23.                 ],
  24.                 'constraints' => [new NotBlank()],
  25.             ])
  26.             ->add('email'EmailType::class, [
  27.                 'attr' => [
  28.                     'class' => 'text-center form-control-lg',
  29.                     'placeholder' => 'email',
  30.                 ],
  31.                 'constraints' => [new NotBlank()],
  32.             ])
  33.             // ->add('agreeTerms', CheckboxType::class, [
  34.                 // 'mapped' => false,
  35.                 // 'constraints' => [
  36.                     // new IsTrue([
  37.                         // 'message' => 'You should agree to our terms.',
  38.                     // ]),
  39.                 // ],
  40.             // ])
  41.             /*
  42.             ->add('plainPassword', PasswordType::class, [
  43.                 // instead of being set onto the object directly,
  44.                 // this is read and encoded in the controller
  45.                 'mapped' => false,
  46.                 'constraints' => [
  47.                     new NotBlank([
  48.                         'message' => 'Please enter a password',
  49.                     ]),
  50.                     new Length([
  51.                         'min' => 6,
  52.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  53.                         // max length allowed by Symfony for security reasons
  54.                         'max' => 4096,
  55.                     ]),
  56.                 ],
  57.             ])
  58.             */
  59.         ;
  60.     }
  61.     public function configureOptions(OptionsResolver $resolver)
  62.     {
  63.         $resolver->setDefaults([
  64.             'data_class' => User::class,
  65.         ]);
  66.     }
  67. }