3 namespace Rapsys\AirBundle\Form
;
5 use Rapsys\PackBundle\Form\CaptchaType
;
7 use Symfony\Component\Form\FormBuilderInterface
;
8 use Symfony\Component\OptionsResolver\OptionsResolver
;
9 use Symfony\Component\Form\Extension\Core\Type\TextType
;
10 use Symfony\Component\Form\Extension\Core\Type\TextareaType
;
11 use Symfony\Component\Form\Extension\Core\Type\EmailType
;
12 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
13 use Symfony\Component\Validator\Constraints\Email
;
14 use Symfony\Component\Validator\Constraints\NotBlank
;
16 class ContactType
extends CaptchaType
{
20 public function buildForm(FormBuilderInterface
$builder, array $options): void {
23 ->add('name', TextType
::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(['message' => 'Please provide your name'])]])
24 ->add('subject', TextType
::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(['message' => 'Please provide your subject'])]])
25 ->add('mail', EmailType
::class, ['attr' => ['placeholder' => 'Your mail'], 'constraints' => [new NotBlank(['message' => 'Please provide a valid mail']), new Email(['message' => 'Your mail doesn\'t seems to be valid'])]])
26 ->add('message', TextareaType
::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your message'])]])
27 ->add('submit', SubmitType
::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
30 parent
::buildForm($builder, $options);
36 public function configureOptions(OptionsResolver
$resolver): void {
38 $resolver->setDefaults(['error_bubbling' => true]);
44 public function getName(): string {
45 return 'contact_form';