<?php
namespace App\Form;
use App\Data\SearchData;
use App\Entity\Seller;
use App\Entity\Category;
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\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class SearchForm extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('q', TextType::class, [
'label' => false,
'required' => false,
'attr' => [
'placeholder' => 'What are you Looking for ?',
],
])
// ->add('categories', EntityType::class, [
// 'label' => false,
// 'required' => false,
// 'class' => Category::class,
// 'choice_label' => 'Name',
// 'expanded' => true,
// 'multiple' => true
// ])
->add('categories', EntityType::class, array(
'class' => Category::class,
'choice_label' => 'name',
'label' => false,
'placeholder' => 'All categories',
'required' => false,
'choice_translation_domain' => 'messages',
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => SearchData::class,
'method' => 'GET',
'csrf_protection' => false,
]);
}
public function getBlockPrefix()
{
return '';
}
}