src/Form/FormConfigurator/TechnicalSupportAnymazeFormType.php line 71

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