]> Raphaël G. Git Repositories - airbundle/blobdiff - Form/ContactType.php
Fix coalesce warning
[airbundle] / Form / ContactType.php
index 24d4d3ec7822b13bd416cf9e799539a72fc470c3..4142c996d4c0bc3dcdcf8a3d13b8c7ffba8f8a7a 100644 (file)
@@ -1,8 +1,18 @@
-<?php
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys AirBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
 
 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,30 +22,41 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 use Symfony\Component\Validator\Constraints\Email;
 use Symfony\Component\Validator\Constraints\NotBlank;
 
-class ContactType extends AbstractType {
+/**
+ * {@inheritdoc}
+ */
+class ContactType extends CaptchaType {
        /**
         * {@inheritdoc}
         */
-       public function buildForm(FormBuilderInterface $builder, array $options) {
-               return $builder
+       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 {
+               //Call parent configure options
+               parent::configureOptions($resolver);
+
+               //Set defaults
                $resolver->setDefaults(['error_bubbling' => true]);
        }
 
        /**
         * {@inheritdoc}
         */
-       public function getName() {
+       public function getName(): string {
                return 'contact_form';
        }
 }