<?php namespace App\Form;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type as Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => 'Imię i Nazwisko *',
'constraints' => new NotBlank(),
])
->add('email', EmailType::class, [
'label' => 'E-mail *',
'constraints' => [
new NotBlank(),
new Email(['mode' => Email::VALIDATION_MODE_STRICT]),
],
])
->add('content', TextareaType::class, [
'label' => 'Wiadomość *',
'constraints' => new NotBlank(),
])
// Honeypot: kept out of the visible layout via CSS in the
// template, so only a bot filling every field it finds ever
// populates it. Not mapped to any entity/array key of its own —
// DefaultController reads it straight off the form to decide
// whether to silently drop the submission.
->add('website', TextType::class, [
'label' => false,
'mapped' => false,
'required' => false,
])
;
}
public function getBlockPrefix(): string
{
return 'contact';
}
}