<?php

namespace App\Form;

use App\Entity\Territory\Territory;
use App\Entity\Thematic\Thematic;
use Lc\PietroBundle\Model\AbstractData;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
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\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SearchListForm extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('search', TextType::class, [
                'required' => false,
                'attr' => [
                    'placeholder' => 'Saisir des critères par mots clés'
                ],
            ])
            ->add('territory', EntityType::class, [
                'label' => 'Lieux',
                'required' => false,
                'class' => Territory::class,
                'expanded' => true,
                'multiple' => true,
            ])
            ->add('category', ChoiceType::class, [
                'label' => 'Catégorie',
                'required' => false,
                'expanded' => true,
                'multiple' => true,
                'choices' => [
                    AbstractData::getCategory()
                ]
            ])
            ->add('thematic', EntityType::class, [
                'label' => 'Thématique',
                'required' => false,
                'class' => Thematic::class,
                'expanded' => true,
                'multiple' => true,
            ])
            ->add('page', HiddenType::class, [
                'required' => false,
                'empty_data' => 1,
                'attr' => [
                    'class' => 'hidden-page'
                ]
            ])
            ->add('search_button', SubmitType::class, [
                'attr' => ['class' => 'search-button'],
            ])
            ->add('export_excel', SubmitType::class, [
                'attr' => ['class' => 'export export-excel'],
            ])
            ->add('export_pdf', SubmitType::class, [
                'attr' => ['class' => 'export export-pdf'],
            ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'csrf_protection' => false,
            ]
        );
    }
}
