src/Form/ContactType.php line 12

Open in your IDE?
  1. <?php namespace App\Form;
  2. use Symfony\Component\Form\Extension\Core\Type\TextType;
  3. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  4. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type as Type;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\Validator\Constraints\Email;
  9. use Symfony\Component\Validator\Constraints\NotBlank;
  10. class ContactType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('name'TextType::class, [
  16.                 'label' => 'Imię i Nazwisko *',
  17.                 'constraints' => new NotBlank(),
  18.             ])
  19.             ->add('email'EmailType::class, [
  20.                 'label' => 'E-mail *',
  21.                 'constraints' => [
  22.                     new NotBlank(),
  23.                     new Email(['mode' => Email::VALIDATION_MODE_STRICT]),
  24.                 ],
  25.             ])
  26.             ->add('content'TextareaType::class, [
  27.                 'label' => 'Wiadomość *',
  28.                 'constraints' => new NotBlank(),
  29.             ])
  30.             // Honeypot: kept out of the visible layout via CSS in the
  31.             // template, so only a bot filling every field it finds ever
  32.             // populates it. Not mapped to any entity/array key of its own —
  33.             // DefaultController reads it straight off the form to decide
  34.             // whether to silently drop the submission.
  35.             ->add('website'TextType::class, [
  36.                 'label' => false,
  37.                 'mapped' => false,
  38.                 'required' => false,
  39.             ])
  40.         ;
  41.     }
  42.     public function getBlockPrefix(): string
  43.     {
  44.         return 'contact';
  45.     }
  46. }