<?php
namespace App\Form\Backend;
use App\Model\Search\AdvancedSearch;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
class AdvancedSearchType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('searchCriteria', CollectionType::class, [
'entry_type' => SearchCriteriumType::class,
'entry_options'=> [
'parameters' => $options['parameters'],
'entityName' => $options['entityName']
],
'label' => false,
'allow_add' => true,
'allow_delete' => true,
])
;
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => AdvancedSearch::class,
'entityName'=> null,
'parameters' => null,
]);
}
}