src/Form/FormConfigurator/TechnicalSupportRequestFormType.php line 30

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore Customer Management Framework Bundle
  4.  * Full copyright and license information is available in
  5.  * LICENSE.md which is distributed with this source code.
  6.  *
  7.  * @copyright  Copyright (C) Elements.at New Media Solutions GmbH
  8.  * @license    GPLv3
  9.  */
  10. namespace App\Form\FormConfigurator;
  11. use Pimcore;
  12. use Pimcore\Model\DataObject\Customer;
  13. use Symfony\Component\Form\AbstractType;
  14. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  15. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  16. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  17. use Symfony\Component\Form\Extension\Core\Type\TextType;
  18. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  19. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  20. use Symfony\Component\Form\FormBuilderInterface;
  21. use Symfony\Component\OptionsResolver\OptionsResolver;
  22. use Symfony\Component\Validator\Constraints\NotBlank;
  23. use Symfony\Component\Form\Form;
  24. use Pimcore\Model\Document\Tag\Area\Info;
  25. use App\Document\Areabrick\AbstractAreabrick;
  26. class TechnicalSupportRequestFormType extends AbstractFormType
  27. {
  28.     protected $formLabel 'Technical Support Request (Polygraph)';
  29.     /**
  30.      * @inheritDoc
  31.      */
  32.     protected $emailDocumentPath '/emails/polygraph/technical-support';
  33.     /**
  34.      * @inheritDoc
  35.      */
  36.     protected $sendConfirmation true;
  37.     protected $recaptcha true;
  38.     /**
  39.      * @inheritDoc
  40.      */
  41.     public function buildForm(FormBuilderInterface $builder, array $options)
  42.     {
  43.         $translator Pimcore::getContainer()->get('translator');
  44.         $customer = new Customer();
  45.         $prefixes $customer->getClass()->getFieldDefinition('prefix');
  46.         $prefixOptions = [ $translator->trans('stoelting.forms.prefix.placeholder') => '' ];
  47.         foreach ($prefixes->getOptions() as $option) {
  48.             $prefixOptions[$option['key']] = $option['value'];
  49.         }
  50.         $builder->add(
  51.                 'Prefix',
  52.                 ChoiceType::class,
  53.                 [
  54.                     'label'    => $translator->trans('stoelting.forms.prefix'),
  55.                     'placeholder' => $translator->trans('stoelting.forms.prefix.placeholder'),
  56.                     'multiple' => false,
  57.                     'choices'  => $prefixOptions,
  58.                     'choice_attr' => function ($key$val$index) {
  59.                         return empty($key) ? ['disabled' => 'disabled'] : [];
  60.                     }
  61.                 ]
  62.             )
  63.             ->add('Firstname'TextType::class, [
  64.                 'label' => $translator->trans('stoelting.forms.firstname'),
  65.                 'attr'        => [
  66.                     'placeholder' => $translator->trans('stoelting.forms.firstname.placeholder'),
  67.                 ],
  68.                 'constraints' => [
  69.                     new NotBlank([
  70.                         'message' => $translator->trans('stoelting.forms.firstname.required.message'),
  71.                     ])
  72.                 ]
  73.             ])
  74.             ->add('Lastname'TextType::class, [
  75.                 'label' => $translator->trans('stoelting.forms.lastname'),
  76.                 'attr'        => [
  77.                     'placeholder' => $translator->trans('stoelting.forms.lastname.placeholder'),
  78.                 ],
  79.                 'constraints' => [
  80.                     new NotBlank([
  81.                         'message' => $translator->trans('stoelting.forms.lastname.required.message'),
  82.                     ])
  83.                 ]
  84.             ])
  85.             ->add('Company'TextType::class, [
  86.                 'label' => $translator->trans('stoelting.forms.company'),
  87.                 'attr'        => [
  88.                     'placeholder' => $translator->trans('stoelting.forms.company.placeholder'),
  89.                 ]
  90.             ])
  91.             ->add('Country'TextType::class, [
  92.                 'label' => $translator->trans('stoelting.forms.country'),
  93.                 'attr'        => [
  94.                     'placeholder' => $translator->trans('stoelting.forms.country.placeholder'),
  95.                     'readonly' => false
  96.                 ],
  97.                 'constraints' => [
  98.                     new NotBlank([
  99.                         'message' => $translator->trans('stoelting.forms.country.required.message'),
  100.                     ])
  101.                 ]
  102.             ])
  103.             ->add('Email'EmailType::class, [
  104.                 'label' => $translator->trans('stoelting.forms.email'),
  105.                 'attr'        => [
  106.                     'placeholder' => $translator->trans('stoelting.forms.email.placeholder'),
  107.                     'readonly' => false
  108.                 ],
  109.                 'constraints' => [
  110.                     new NotBlank([
  111.                         'message' => $translator->trans('stoelting.forms.email.required.message'),
  112.                     ])
  113.                 ]
  114.             ])
  115.             ->add('Phone'TextType::class, [
  116.                 'label' => $translator->trans('stoelting.forms.phone'),
  117.                 'attr'        => [
  118.                     'placeholder' => $translator->trans('stoelting.forms.phone.placeholder'),
  119.                     'readonly' => false
  120.                 ],
  121.                 'constraints' => [
  122.                     new NotBlank([
  123.                         'message' => $translator->trans('stoelting.forms.phone.required.message'),
  124.                     ])
  125.                 ]
  126.             ])
  127.             ->add('Message'TextareaType::class, [
  128.                 'label' => $translator->trans('stoelting.forms.message'),
  129.                 'attr'        => [
  130.                     'placeholder' => $translator->trans('stoelting.forms.message.placeholder'),
  131.                     'readonly' => false,
  132.                     'rows' => 5,
  133.                     'max' => 500
  134.                 ],
  135.                 'constraints' => [
  136.                     new NotBlank([
  137.                         'message' => $translator->trans('stoelting.forms.message.required.message'),
  138.                     ])
  139.                 ]
  140.             ])
  141.             ->add('g-recaptcha-response'HiddenType::class, [
  142.                 'attr' => [
  143.                     'id' => 'g-recaptcha-response'
  144.                 ],
  145.             ])
  146.             ->add('action'HiddenType::class, [
  147.                 'attr' => [
  148.                     'id' => 'validate_captcha'
  149.                 ],
  150.                 'data' => 'requestAQuoteNeuroForm'
  151.             ])
  152.             ->add('_submit'SubmitType::class, [
  153.                 'label' => $translator->trans('stoelting.forms.send'),
  154.                 'attr' => [
  155.                     'class' => 'btn btn-primary',
  156.                     'onclick' => 'onSubmit()'
  157.                 ]
  158.             ]);
  159.     }
  160.     /**
  161.      * @inheritDoc
  162.      */
  163.     public function getBlockPrefix()
  164.     {
  165.         return '';
  166.     }
  167.     /**
  168.      * @inheritDoc
  169.      */
  170.     public function configureOptions(OptionsResolver $resolver)
  171.     {
  172.     }
  173. }