src/Form/ContactForm.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Dictionary\ReviewTypeForm;
  4. use App\Entity\ReviewComment;
  5. use App\Repository\ReviewServiceAreaRepository;
  6. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  10. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextType;
  12. use Symfony\Component\Form\FormBuilderInterface;
  13. use Symfony\Component\OptionsResolver\OptionsResolver;
  14. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  15. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  16. use Symfony\Component\Validator\Constraints\Email;
  17. use Symfony\Component\Validator\Constraints\Length;
  18. use Symfony\Component\Validator\Constraints\NotBlank;
  19. /**
  20.  * Formularz kontaktowy
  21.  */
  22. class ContactForm extends AbstractType
  23. {
  24.     public function buildForm(FormBuilderInterface $builder, array $options)
  25.     {
  26.         $builder
  27.             ->add('signature'TextType::class, array(
  28.                 'label' => 'Podpis',
  29.                 'required' => true,
  30.                 'constraints' => [
  31.                     new NotBlank([
  32.                         'message' => 'To pole nie może być puste'
  33.                     ]),
  34.                     new Length([
  35.                         'min' => 3,
  36.                         'max' => 50,
  37.                         'minMessage' => 'Minimalna liczba znaków wynosi 3',
  38.                         'maxMessage' => 'Maksymalna liczna znaków wynosi 50'
  39.                     ])
  40.                 ],
  41.                 'attr' =>
  42.                     array(
  43.                         'maxlength' => 50,
  44.                         'placeholder' => 'podpis',
  45.                         'class' => 'form-control'
  46.                     )
  47.             ))
  48.             ->add('email'EmailType::class, array(
  49.                 'label' => 'twój adres e-mail',
  50.                 'required' => false,
  51.                 'constraints' => [
  52.                     new NotBlank([
  53.                         'message' => 'To pole nie może być puste'
  54.                     ]),
  55.                     new Email([
  56.                         'message' => 'Niepoprawny adres e-mail'
  57.                     ])
  58.                 ],
  59.                 'attr' =>
  60.                     array(
  61.                         'maxlength' => 150,
  62.                         'placeholder' => 'e-mail',
  63.                         'class' => 'form-control'
  64.                     )
  65.             ))
  66.             ->add('description'TextareaType::class, array(
  67.                 'label' => false,
  68.                 'required' => true,
  69.                 'constraints' => [
  70.                     new NotBlank([
  71.                         'message' => 'To pole nie może być puste'
  72.                     ]),
  73.                     new Length([
  74.                         'min' => 10,
  75.                         'max' => 5000,
  76.                         'minMessage' => 'Minimalna liczba znaków wynosi 10',
  77.                         'maxMessage' => 'Maksymalna liczna znaków wynosi 5000'
  78.                     ])
  79.                 ],
  80.                 'attr' =>
  81.                     array(
  82.                         'maxlength' => 5000,
  83.                         'class' => 'form-control',
  84.                         'rows' => 10,
  85.                         'placeholder' => 'treść wiadomości'
  86.                     )
  87.             ))
  88.             ->add('save'SubmitType::class, array(
  89.                 'label' => 'Wyślij',
  90.                 'attr' =>
  91.                     array(
  92.                         'class' => 'g-recaptcha btn-primary',
  93.                         'data-sitekey' => "6LdJaoAlAAAAAFiu2MBDOKF4czKzGHV9W_I05Wmv",
  94.                         'data-callback' => "onSubmit",
  95.                         'data-action' => "submit"
  96.                     )
  97.             ));
  98.     }
  99. }