X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/f110b8ba20232e0ceeb67390f8e672431868d32d..6f3158f30f33264488887f5a0c8e271cb7d17747:/Form/ContactType.php diff --git a/Form/ContactType.php b/Form/ContactType.php index e9a5ba1..adee525 100644 --- a/Form/ContactType.php +++ b/Form/ContactType.php @@ -2,7 +2,8 @@ namespace Rapsys\AirBundle\Form; -use Symfony\Component\Form\AbstractType; +use Rapsys\PackBundle\Form\CaptchaType; + use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -12,29 +13,35 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\NotBlank; -class ContactType extends AbstractType { +class ContactType extends CaptchaType { /** * {@inheritdoc} */ - public function buildForm(FormBuilderInterface $builder, array $options) { - return $builder->add('name', TextType::class, array('attr' => array('placeholder' => 'Your name'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your name'))))) - ->add('subject', TextType::class, array('attr' => array('placeholder' => 'Subject'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your subject'))))) - ->add('mail', EmailType::class, array('attr' => array('placeholder' => 'Your mail address'), 'constraints' => array(new NotBlank(array('message' => 'Please provide a valid mail')), new Email(array('message' => 'Your mail doesn\'t seems to be valid'))))) - ->add('message', TextareaType::class, array('attr' => array('placeholder' => 'Your message here', 'cols' => 50, 'rows' => 15), 'constraints' => array(new NotBlank(array('message' => 'Please provide your message'))))) - ->add('submit', SubmitType::class, array('label' => 'Send', 'attr' => array('class' => 'submit'))); + public function buildForm(FormBuilderInterface $builder, array $options): void { + //Add fields + $builder + ->add('name', TextType::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(['message' => 'Please provide your name'])]]) + ->add('subject', TextType::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(['message' => 'Please provide your subject'])]]) + ->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'])]]) + ->add('message', TextareaType::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your message'])]]) + ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]); + + //Call parent + parent::buildForm($builder, $options); } /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) { + public function configureOptions(OptionsResolver $resolver): void { + //Set defaults $resolver->setDefaults(['error_bubbling' => true]); } /** * {@inheritdoc} */ - public function getName() { + public function getName(): string { return 'contact_form'; } }