<?php

namespace App\Form\Frontend;

use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\OptionsResolver\OptionsResolver;


use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;

class UserInfoPersoType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('firstname', TextType::class, array(
                'label' => 'Prénom',
                'required' => true
            ))
            ->add('lastname', TextType::class, array(
                'label' => 'Nom',
                'required' => true
            ))
            ->add('birthdate', BirthdayType::class, array(
                'label' => 'Date de naissance',
                'format' => 'dd/MM/yyyy',
                'widget' => 'single_text',
                'html5' => false,
                'attr' => [
                    'class'=> 'datepicker form-control unicase-form-control',
                ]
            ))
            ->add('phoneNumber', TextType::class, array(
                'label' => 'Numéro Téléphone',
                'required' => true
            ))
            ->add('gender', ChoiceType::class, array(
                'label' => 'Gender',
                'choices' => ['Femme' => 0, 'Homme' => 1 ],
                'required' => true
            ))
            ->add("save", SubmitType::class, ['attr'=>['class'=>'save']])
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => User::class,
        ]);
    }
}
