src/Form/CollabrationFormType.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 CollabrationFormType 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('company'TextType::class, [
  57.                 'label' => 'Ragione sociale',
  58.                 'attr' => ['class' => 'form-control col-sm-4'],
  59.                 'required' => false,
  60.             ])
  61.             ->add('phone'TextType::class, [
  62.                 'label' => 'Telefono',
  63.                 'attr' => ['class' => 'form-control col-sm-4'],
  64.                 'required' => false,
  65.             ])
  66.             ->add('message'TextareaType::class, [
  67.                 'label' => 'Messaggio',
  68.                 'attr' => ['class' => 'form-control col-sm-10'],
  69.                 'required' => true,
  70.             ])           
  71.             ->add('consent'CheckboxType::class, [
  72.                 'label' => 'Contsent',
  73.                 'attr' => ['class' => 'custom-control-input mr-2'],
  74.                 'required' => true,
  75.             ])
  76.             ->add('file_upload'FileType::class, [
  77.                 'label' => 'File',
  78.                 'attr' => ['class' => 'custom-file-input'],
  79.                 // unmapped means that this field is not associated to any entity property
  80.                 'mapped' => false,
  81.                 // make it optional so you don't have to re-upload the PDF file
  82.                 // every time you edit the Product details
  83.                 'required' => false,
  84.                 // unmapped fields can't define their validation using annotations
  85.                 // in the associated entity, so you can use the PHP constraint classes
  86.                 'constraints' => [
  87.                     new File([
  88.                         'maxSize' => '5024k',                       
  89.                         'mimeTypesMessage' => 'Caricare un documento valido',
  90.                     ])
  91.                 ],
  92.             ])           
  93.             ->add('_target_path'HiddenType::class)
  94.             ->add('_submit'SubmitType::class, [
  95.                 'label' => 'Invia proposta',
  96.                 'attr' => ['class' => 'btn c-button yellow']
  97.             ]);
  98.     }
  99.     /**
  100.      * @inheritDoc
  101.      */
  102.     public function getBlockPrefix()
  103.     {
  104.         // we need to set this to an empty string as we want _username as input name
  105.         // instead of login_form[_username] to work with the form authenticator out
  106.         // of the box
  107.         return '';
  108.     }
  109.     /**
  110.      * @inheritDoc
  111.      */
  112.     public function configureOptions(OptionsResolver $resolver)
  113.     {
  114.     }
  115. }