src/Form/ContactFormType.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  7. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Form\Extension\Core\Type\TimeType;
  13. use Symfony\Component\Form\Extension\Core\Type\DateType;
  14. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  15. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  16. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  17. use Symfony\Component\Form\Extension\Core\Type\TelType;
  18. use Symfony\Component\Form\Extension\Core\Type\FileType;
  19. use Symfony\Component\Validator\Constraints\File;
  20. use Symfony\Component\Validator\Constraints\Email;
  21. use Symfony\Component\Validator\Constraints\NotBlank;
  22. use Symfony\Component\Validator\Constraints\Choice;
  23. class ContactFormType extends AbstractType
  24. {
  25.     /**
  26.      * @inheritDoc
  27.      */
  28.     public function buildForm(FormBuilderInterface $builder, array $options)
  29.     {
  30.         $builder
  31.             ->add('name'TextType::class, [
  32.                 'label'    => 'form.contact.Name',
  33.                 'required' => false,
  34.                 'error_bubbling' => true,
  35.                 'constraints' => [
  36.                     new NotBlank(['message' => 'form.contact.Name.not.blank'])
  37.                 ],
  38.                 'attr'     => [
  39.                     'placeholder' => 'form.contact.Name'
  40.                 ]
  41.             ])
  42.             ->add('lastname'TextType::class, [
  43.                 'label'    => 'form.contact.Lastname',
  44.                 'required' => false,
  45.                 'error_bubbling' => true,
  46.                 'constraints' => [
  47.                     new NotBlank(['message' => 'form.contact.Lastname.not.blank'])
  48.                 ],
  49.                 'attr'     => [
  50.                     //'style' => 'height: 250px;'
  51.                     'placeholder' => 'form.contact.Lastname'
  52.                 ]
  53.             ])
  54.             /*->add('company', TextType::class, [
  55.                 'label'    => 'form.contact.Company',
  56.                 'required' => false,
  57.                 'error_bubbling' => true,
  58.                 'constraints' => [
  59.                     new NotBlank(['message' => 'form.contact.Company.not.blank'])
  60.                 ],
  61.                 'attr'     => [
  62.                     //'style' => 'height: 250px;'
  63.                     'placeholder' => 'form.contact.Company'
  64.                 ]
  65.             ])*/
  66.             ->add('tel'TextType::class, [
  67.                 'label'    => 'form.contact.Tel',
  68.                 'required' => false,
  69.                 'error_bubbling' => true,
  70.                 'constraints' => [
  71.                     new NotBlank(['message' => 'form.contact.Tel.not.blank'])
  72.                 ],
  73.                 'attr'     => [
  74.                     //'style' => 'height: 250px;'
  75.                     'placeholder' => 'form.contact.Tel'
  76.                 ]
  77.             ])
  78.             ->add('message'TextareaType::class, [
  79.                 'label'    => 'form.contact.Message',
  80.                 'required' => false,
  81.                 'error_bubbling' => true,
  82.                 'attr'     => [
  83.                     //'style' => 'height: 250px;'
  84.                     'placeholder' => 'form.contact.Message'
  85.                 ],
  86.                 'constraints' => [
  87.                     new NotBlank(['message' => 'form.contact.Message.not.blank'])
  88.                 ],
  89.             ])
  90.             // email
  91.             ->add('email'EmailType::class, [
  92.                 'label' => 'form.contact.email',
  93.                 'attr' => [
  94.                     'placeholder' => 'form.contact.email'
  95.                 ],
  96.                 'required' => false,
  97.                 'error_bubbling' => true,
  98.                 'constraints' => [
  99.                     new NotBlank(['message' => 'form.contact.email.not.blank']),
  100.                     new Email(['message' => 'form.contact.email.not-valid'])
  101.                 ]
  102.             ])
  103.             // vr_mandat_pdf
  104.             /*
  105.             ->add('vr_mandat_pdf', FileType::class, [
  106.                 'label' => 'vr_mandat_pdf',
  107.                 'attr' => [
  108.                     'placeholder' => '',
  109.                     'class' => 'original-file-input',
  110.                     'data-file' => '1',
  111.                     'accept' => '.pdf'
  112.                 ],
  113.                 'required' => false,
  114.                 'error_bubbling' => false,
  115.                 'constraints' => [
  116.                     new File([
  117.                         'maxSize' => '5000k',
  118.                         'maxSizeMessage' => 'vr-mandat_pdf.toobig',
  119.                         'mimeTypes' => [
  120.                             'application/pdf'
  121.                         ],
  122.                         'mimeTypesMessage' => 'vr-mandat_pdf.wrongtype'
  123.                     ])
  124.                 ]
  125.             ])
  126.             */
  127.             ->add('disclaimer'CheckboxType::class, [
  128.                 'label'    => 'disclaimer_gelesen_und_akzeptiert',
  129.                 'required' => false,
  130.                 'attr' => [
  131.                     'class' => 'disclaimer-proof'
  132.                 ],
  133.                 'error_bubbling' => true,
  134.                 'constraints' => [
  135.                     new NotBlank(['message' => 'form.contact.disclaimer.not.blank'])
  136.                 ]
  137.             ])
  138.             // hidden
  139.             ->add('hidden'HiddenType::class, [
  140.                 'required' => false
  141.             ])
  142.             // js filled
  143.             ->add('filled'HiddenType::class, [
  144.                 'required' => true
  145.             ])
  146.             ->add('submit'SubmitType::class, [
  147.                 'label' => 'absenden'
  148.             ]);
  149.     }
  150.     /**
  151.      * @inheritDoc
  152.      */
  153.     public function configureOptions(OptionsResolver $resolver)
  154.     {
  155.     }
  156. }