<?php
declare(strict_types=1);
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class ContactFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => 'app.general.gemini.contactform.name',
'required' => true,
'constraints' => [
new NotBlank(),
new Length(['min' => 3]),
],
])
->add('surname', TextType::class, [
'label' => 'app.general.gemini.contactform.surname',
'required' => true,
'constraints' => [
new NotBlank(),
new Length(['min' => 3]),
],
])
->add('email', TextType::class, [
'label' => 'app.general.gemini.contactform.email',
'required' => true,
'constraints' => [
new NotBlank(),
new Length(['min' => 3]),
],
])
->add('company', TextType::class, [
'label' => 'app.general.gemini.contactform.company',
'required' => false,
])
->add('message', TextType::class, [
'label' => 'app.general.gemini.contactform.message',
'required' => true,
'constraints' => [
new NotBlank(),
new Length(['min' => 3]),
],
])
->add('phone', TextType::class, [
'label' => 'app.general.gemini.contactform.phone',
'required' => false,
])
->add('topic', ChoiceType::class, [
'label' => 'app.general.gemini.contactform.topic',
'required' => true,
'expanded' => true,
'multiple' => false,
'choices' => [
'app.general.gemini.contactform.topic2' => 'office',
'app.general.gemini.contactform.topic1' => 'suppliers',
'app.general.gemini.contactform.topic3' => 'renting',
'app.general.gemini.contactform.topic4' => 'GDPR',
],
'constraints' => [
new NotBlank(),
new Length(['min' => 3]),
],
])
->add('subject', TextType::class, [
'label' => 'app.general.gemini.contactform.subject',
'required' => false,
])
->add('agreement1', CheckboxType::class, [
'label' => 'app.general.gemini.contactform.agreement1',
'required' => true,
'constraints' => [
new IsTrue([
'message' => 'app.general.gemini.form.checkboxvalidation',
]),
],
])
->add('_submit', SubmitType::class, [
'label' => 'app.general.gemini.contactform.submit',
'attr' => [
'class' => 'col-5 primary-btn orange-btn',
],
]);
}
}