<?php
namespace CustomBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type as InputType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Validator\Constraints as CustomAssert;
class TopPageRestaurantSearchType extends AbstractType
{
public function getBlockPrefix()
{
return '';
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$genres = $options['genres'];
$time_by_cars = $options['time_by_cars'];
$scenes = $options['scenes'];
$features = $options['features'];
$builder->add('genre', InputType\ChoiceType::class, [
'required' => false,
'label' => 'ジャンル',
'constraints' => [],
'expanded' => false,
'multiple' => false,
'placeholder' => 'ジャンル',
'choices' => array_flip($genres)
]);
$builder->add('time_by_car', InputType\ChoiceType::class, [
'required' => false,
'label' => '車での距離',
'constraints' => [],
'expanded' => false,
'multiple' => false,
'placeholder' => 'ジブリパークからの距離',
'choices' => array_flip($time_by_cars)
]);
$builder->add('scene', InputType\ChoiceType::class, [
'required' => false,
'label' => '利用シーン',
'constraints' => [],
'expanded' => false,
'multiple' => false,
'placeholder' => '利用シーン',
'choices' => array_flip($scenes)
]);
$builder->add('feature', InputType\ChoiceType::class, [
'required' => false,
'label' => '特徴',
'constraints' => [],
'expanded' => false,
'multiple' => false,
'placeholder' => '特徴',
'choices' => array_flip($features)
]);
}
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'genres' => null,
'time_by_cars' => null,
'scenes' => null,
'features' => null,
'allow_extra_fields' => true, // ?page=のエラーを出さない用
]);
}
}