]> Raphaël G. Git Repositories - airbundle/commitdiff
Inherit captcha type
authorRaphaël Gertz <git@rapsys.eu>
Tue, 4 Oct 2022 07:50:02 +0000 (09:50 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 4 Oct 2022 07:50:02 +0000 (09:50 +0200)
Call parent build form
Cleanup

Form/ContactType.php

index 24d4d3ec7822b13bd416cf9e799539a72fc470c3..8e5946e8138ef99de557c13f66894df33466b860 100644 (file)
@@ -2,7 +2,8 @@
 
 namespace Rapsys\AirBundle\Form;
 
 
 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;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolver;
 use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -12,23 +13,28 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 use Symfony\Component\Validator\Constraints\Email;
 use Symfony\Component\Validator\Constraints\NotBlank;
 
 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) {
        /**
         * {@inheritdoc}
         */
        public function buildForm(FormBuilderInterface $builder, array $options) {
-               return $builder
+               //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']]);
                        ->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) {
        }
 
        /**
         * {@inheritdoc}
         */
        public function configureOptions(OptionsResolver $resolver) {
+               //Set defaults
                $resolver->setDefaults(['error_bubbling' => true]);
        }
 
                $resolver->setDefaults(['error_bubbling' => true]);
        }