src/Flexy/FrontBundle/Themes/IlaveU/Form/UserPasswordFormType.php line 20

  1. <?php
  2. namespace App\Flexy\FrontBundle\Themes\IlaveU\Form;
  3. use App\Entity\User;
  4. use App\Flexy\ShopBundle\Entity\Customer\Customer;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints\IsTrue;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  14. use Symfony\Component\Form\Extension\Core\Type\DateType;
  15. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  16. use Symfony\Component\Validator\Constraints\Email;
  17. class UserPasswordFormType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {
  21.         $builder
  22.             ->add('password'PasswordType::class, [
  23.                 // instead of being set onto the object directly,
  24.                 // this is read and encoded in the controller
  25.                 
  26.                 
  27.                 'attr' => ['autocomplete' => 'new-password'],
  28.                 'constraints' => [
  29.                     new NotBlank([
  30.                         'message' => 'Please enter a password',
  31.                     ]),
  32.                     new Length([
  33.                         'min' => 6,
  34.                         'minMessage' => 'Your password should be at least {{ limit }} characters',
  35.                         // max length allowed by Symfony for security reasons
  36.                         'max' => 4096,
  37.                     ]),
  38.                 ],
  39.             ])
  40.         ;
  41.     }
  42.     public function configureOptions(OptionsResolver $resolver): void
  43.     {
  44.         $resolver->setDefaults([
  45.             'data_class' => User::class,
  46.         ]);
  47.     }
  48. }