src/Form/VRQuoteType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Component\Configuration\Util\Config;
  4. use App\Component\ReCaptcha\Form\ReCaptchaType;
  5. use App\Entity\VRQuote;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Flagception\Manager\FeatureManagerInterface;
  8. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  11. use Symfony\Component\Form\Extension\Core\Type\DateType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextType;
  13. use Symfony\Component\Form\FormBuilderInterface;
  14. use Symfony\Component\OptionsResolver\OptionsResolver;
  15. class VRQuoteType extends AbstractType
  16. {
  17.     /**
  18.      * @var EntityManagerInterface
  19.      */
  20.     protected $manager;
  21.     /**
  22.      * @var FeatureManagerInterface
  23.      */
  24.     protected $featureManager;
  25.     /**
  26.      * @var ParameterBagInterface
  27.      */
  28.     private $config;
  29.     private $hotelChoices = [
  30.         '3 sterren' => 3,
  31.         '4 sterren' => 4,
  32.         '5 sterren' => 5,
  33.     ];
  34.     private $transportChoices = [
  35.         'Eigen vervoer' => 'Eigen vervoer',
  36.         'Vliegtuig' => 'Vliegtuig',
  37.         'Trein' => 'Trein',
  38.         'Boot' => 'Boot',
  39.     ];
  40.     /**
  41.      * ContactType constructor.
  42.      */
  43.     public function __construct(
  44.         EntityManagerInterface $manager,
  45.         FeatureManagerInterface $featureManager,
  46.         Config $config,
  47.     ) {
  48.         $this->manager $manager;
  49.         $this->featureManager $featureManager;
  50.         $this->config $config;
  51.     }
  52.     /**
  53.      * {@inheritdoc}
  54.      */
  55.     public function buildForm(FormBuilderInterface $builder, array $options)
  56.     {
  57.         $builder
  58.             ->add('name')
  59.             ->add('lastname')
  60.             ->add('city')
  61.             ->add('companyname')
  62.             ->add('telephone')
  63.             ->add('email')
  64.             ->add('matchChoice'TextType::class, [
  65.                 'required' => true,
  66.             ])
  67.             ->add('dateFrom'DateType::class, [
  68.                 'widget' => 'single_text',
  69.                 'required' => false,
  70.             ])
  71.             ->add('dateUntil'DateType::class, [
  72.                 'widget' => 'single_text',
  73.                 'required' => false,
  74.             ])
  75.             ->add('transportation'ChoiceType::class, [
  76.                 'choices' => $this->transportChoices,
  77.             ])
  78.             ->add('numberOfPersons'TextType::class, [
  79.                 'required' => true,
  80.             ])
  81.             ->add('budget')
  82.             ->add('typeHotel'ChoiceType::class, [
  83.                 'choices' => $this->hotelChoices,
  84.             ])
  85.             ->add('remarks')
  86.             ->add('recaptcha'ReCaptchaType::class);
  87.         if ($this->config->get('site_contact_privacy_statement_option')) {
  88.             $builder->add('privacy_statement'CheckboxHtmlType::class, [
  89.                 'label' => $this->config->get('site_contact_privacy_statement_text'),
  90.                 'mapped' => false,
  91.                 'required' => true,
  92.             ]);
  93.         }
  94.     }
  95.     /**
  96.      * {@inheritdoc}
  97.      */
  98.     public function configureOptions(OptionsResolver $resolver)
  99.     {
  100.         $resolver->setDefaults([
  101.             'data_class' => VRQuote::class,
  102.             'translation_domain' => 'contact',
  103.             'attr' => [
  104.                 'class' => 'recaptcha-form',
  105.             ],
  106.             'recaptcha_vrquote' => null,
  107.         ]);
  108.     }
  109. }