src/Form/RegistrationFormType.php line 22
<?phpnamespace App\Form;use App\Entity\User;use Symfony\Component\Form\AbstractType;use Symfony\Component\Form\Extension\Core\Type\BirthdayType;use Symfony\Component\Form\Extension\Core\Type\CheckboxType;use Symfony\Component\Form\Extension\Core\Type\FileType;use Symfony\Component\Form\Extension\Core\Type\PasswordType;use Symfony\Component\Form\Extension\Core\Type\RepeatedType;use Symfony\Component\Form\FormBuilderInterface;use Symfony\Component\OptionsResolver\OptionsResolver;use Symfony\Component\Validator\Constraints\Length;use Symfony\Component\Validator\Constraints\NotBlank;use Symfony\Component\Form\Extension\Core\Type\ChoiceType;use Symfony\Component\Form\Extension\Core\Type\TextType;use Symfony\Component\Form\Extension\Core\Type\EmailType;use Symfony\Component\Form\Extension\Core\Type\DateType;use Symfony\Component\Validator\Constraints\File;class RegistrationFormType extends AbstractType{public function buildForm(FormBuilderInterface $builder, array $options): void{$builder->add('nom', TextType::class, ['label' => false,])->add('prenom', TextType::class, ['label' => false])->add('sexe', ChoiceType::class, ['label' => 'Sexe : ','attr' => ['class' => 'question'],'choices' => ['Homme' => 'homme','Femme' => 'femme',],'choice_attr' => ['Homme' => ['class' => 'custom-space'],'Femme' => ['class' => 'custom-space'],],'expanded' => true,])->add('email', EmailType ::class, ['label' => false,])->add('photo', FileType::class, ['label' => false,// unmapped means that this field is not associated to any entity property'mapped' => false,// make it optional so you don't have to re-upload the PDF file// every time you edit the Product details'required' => false,// unmapped fields can't define their validation using annotations// in the associated entity, so you can use the PHP constraint classes'constraints' => [new File(['maxSize' => '1024k','extensions' => ['jpg','png'],'mimeTypesMessage' => 'Please upload a valid document',])],])->add('date_naissance', DateType::class, ['label' => false,'invalid_message' => 'non valide','required' => true,'widget' => 'single_text',// this is actually the default format for single_text'format' => 'yyyy-MM-dd',])->add('password', RepeatedType::class, [// instead of being set onto the object directly,// this is read and encoded in the controller'mapped' => false,'type' => PasswordType::class,'attr' => ['autocomplete' => 'new-password'],'first_options' => ['label' => false],'second_options' => ['label' => false],'invalid_message' => 'Les mots de passe ne sont pas identiques','constraints' => [new Length(['min' => 4, 'minMessage' => 'le mot de passe doit comporter au moins {{ limit }} caractères', 'max' => 20, 'maxMessage' => 'le mot de passe ne peut pas contenir plus de {{ limit }} caractères'])],]);}public function configureOptions(OptionsResolver $resolver): void{$resolver->setDefaults(['data_class' => User::class,'csrf_protection' => true,// the name of the hidden HTML field that stores the token'csrf_field_name' => '_token',// an arbitrary string used to generate the value of the token// using a different string for each form improves its security'csrf_token_id' => 'task_item',]);}}