<?php

namespace App\Form;

use App\Entity\Filial;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository;

class ReportFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('filial', EntityType::class, [
                'class' => Filial::class,
                'query_builder' => function (EntityRepository $er) {
                    return $er
                        ->createQueryBuilder('f')
                        ->groupBy('f.fid')
                        ->orderBy('f.fid', 'ASC');
                },
                'choice_label' => function ($data) {
                    return $data->getAddress();
                },
                'choice_value' => 'siteId',
                'mapped' => false,
                'multiple' => false, 
                'empty_data' => false,
                'required' => true
            ])
            ;
            // ->add('smsCode',TextType::class, ['mapped' => false]);
    }
}
