<?php


namespace AutoAdmin\Bundle\Admin\Form\Type\Component;


use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

class RichSelect extends AbstractHelperType
{
    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);

        $resolver->setDefaults(
            [
                'multiple' => false,
                'expanded' => false,
//                'empty_label'=> 'aucun(e)',
                'placeholder' => 'aucun(e)',
            ]
        );

        $resolver->setDefault('disable_js_sorting', false);
    }

    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $this->addViewClass($view, 'aa-ft-select-rich');

        if ($options['disable_js_sorting'] === true) {
            $this->addViewClass($view, 'aa-ft-unsorted');
        }
    }

    public function getParent(): string
    {
        return ChoiceType::class;
    }
}
