<?php

namespace App\Dto\Ag;

use App\Entity\Ag\Main;
use App\Entity\Members;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class   AgTypeEdit extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('agDateAt',DateTimeType::class,[
                'label' => 'Date de l\'Assemblée Générale',
                'required' => true,
            ])
            ->add('type',ChoiceType::class,[
                'label' => 'Type de l\'AG',
                'required' => true,
                'choices' => [
                    'Ordinaire' => 'Ordinaire',
                    'Extraordinaire' => 'Extraordinaire'
                ]
            ])
            ->add('locate',TextType::class,[
                'label' => 'Adresse',
                'required' => true,
            ])
            ->add('locateCity',TextType::class,[
                'label' => 'Ville',
                'required' => true,
            ])
            ->add('locateZipcode',TextType::class,[
                'label' => 'Code postal',
                'required' => true,
            ])
            ->add('president',EntityType::class,[
                'label' => 'President de la scéance',
                'class' => Members::class,
                'choice_label' => function (Members $member) {
                    return $member->getPseudo()." - ".$member->getRole();
                }
            ])
            ->add('secretaire',EntityType::class,[
                'label' => 'Secretaire de la scéance',
                'class' => Members::class,
                'choice_label' => function (Members $member) {
                    return $member->getPseudo()." - ".$member->getRole();
                }
            ])
            ->add('closedAt',DateTimeType::class,[
                'label' => 'Date de cloture',
                'required' => false,
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefault('data_class',Main::class);
    }
}
