src/Form/WorkWithUsFormType.php line 32

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. namespace App\Form;
  15. use Pimcore\Localization\LocaleService;
  16. use Symfony\Component\Form\AbstractType;
  17. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  18. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  19. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  20. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  21. use Symfony\Component\Form\Extension\Core\Type\TextType;
  22. use Symfony\Component\Form\FormBuilderInterface;
  23. use Symfony\Component\OptionsResolver\OptionsResolver;
  24. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  25. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  26. use Symfony\Component\Form\Extension\Core\Type\FileType;
  27. use Symfony\Component\Validator\Constraints\File;
  28. class WorkWithUsFormType extends AbstractType
  29. {    
  30.     /**
  31.      * @inheritDoc
  32.      */
  33.     public function buildForm(FormBuilderInterface $builder, array $options)
  34.     {       
  35.         $builder            
  36.             ->add('firstname'TextType::class, [
  37.                 'label' => 'Nome',
  38.                 'attr' => ['class' => 'form-control col-sm-4'],
  39.                 'required' => true,
  40.             ])
  41.             ->add('lastname'TextType::class, [
  42.                 'label' => 'Cognome',
  43.                 'attr' => ['class' => 'form-control col-sm-4'],
  44.                 'required' => true,
  45.             ])
  46.             ->add('email'EmailType::class, [
  47.                 'label' => 'Email',
  48.                 'attr' => ['class' => 'form-control col-sm-4'],
  49.                 'required' => true,
  50.             ])  
  51.             ->add('city'TextType::class, [
  52.                 'label' => 'Città',
  53.                 'attr' => ['class' => 'form-control col-sm-4'],
  54.                 'required' => false,
  55.             ])
  56.             ->add('cap'TextType::class, [
  57.                 'label' => 'CAP',
  58.                 'attr' => ['class' => 'form-control col-sm-4'],
  59.                 'required' => false,
  60.             ])
  61.             ->add('area_of_interest'TextType::class, [
  62.                 'label' => 'Area di interesse',
  63.                 'attr' => ['class' => 'form-control col-sm-4'],
  64.                 'required' => false,
  65.             ])
  66.             ->add('filiale'TextType::class, [
  67.                 'label' => 'Filiale',
  68.                 'attr' => ['class' => 'form-control col-sm-4'],
  69.                 'required' => false,
  70.             ])
  71.             ->add('phone'TextType::class, [
  72.                 'label' => 'Telefono',
  73.                 'attr' => ['class' => 'form-control col-sm-4'],
  74.                 'required' => false,
  75.             ])                    
  76.             ->add('consent'CheckboxType::class, [
  77.                 'label' => 'Contsent',
  78.                 'attr' => ['class' => 'custom-control-input mr-2'],
  79.                 'required' => true,
  80.             ])
  81.             ->add('file_upload'FileType::class, [
  82.                 'label' => 'File',
  83.                 'attr' => ['class' => 'custom-file-input'],
  84.                 // unmapped means that this field is not associated to any entity property
  85.                 'mapped' => false,
  86.                 // make it optional so you don't have to re-upload the PDF file
  87.                 // every time you edit the Product details
  88.                 'required' => false,
  89.                 // unmapped fields can't define their validation using annotations
  90.                 // in the associated entity, so you can use the PHP constraint classes
  91.                 'constraints' => [
  92.                     new File([
  93.                         'maxSize' => '5024k',                       
  94.                         'mimeTypesMessage' => 'Caricare un documento valido',
  95.                     ])
  96.                 ],
  97.             ])           
  98.             ->add('_target_path'HiddenType::class)
  99.             ->add('_submit'SubmitType::class, [
  100.                 'label' => 'Invia candidatura',
  101.                 'attr' => ['class' => 'btn c-button yellow']
  102.             ]);
  103.     }
  104.     /**
  105.      * @inheritDoc
  106.      */
  107.     public function getBlockPrefix()
  108.     {
  109.         // we need to set this to an empty string as we want _username as input name
  110.         // instead of login_form[_username] to work with the form authenticator out
  111.         // of the box
  112.         return '';
  113.     }
  114.     /**
  115.      * @inheritDoc
  116.      */
  117.     public function configureOptions(OptionsResolver $resolver)
  118.     {
  119.     }
  120. }