1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys BlogBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\BlogBundle\Form
;
14 use Symfony\Component\Form\FormBuilderInterface
;
15 use Symfony\Component\OptionsResolver\OptionsResolver
;
16 use Symfony\Component\Form\Extension\Core\Type\TextType
;
17 use Symfony\Component\Form\Extension\Core\Type\TextareaType
;
18 use Symfony\Component\Form\Extension\Core\Type\EmailType
;
19 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
20 use Symfony\Component\Validator\Constraints\Email
;
21 use Symfony\Component\Validator\Constraints\NotBlank
;
23 use Rapsys\PackBundle\Form\CaptchaType
;
25 class ContactType
extends CaptchaType
{
29 public function buildForm(FormBuilderInterface
$builder, array $options): void {
32 ->add('name', TextType
::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(['message' => 'Please provide your name'])]])
33 ->add('subject', TextType
::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(['message' => 'Please provide your subject'])]])
34 ->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'])]])
35 ->add('message', TextareaType
::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your message'])]])
36 ->add('submit', SubmitType
::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
39 parent
::buildForm($builder, $options);
45 public function configureOptions(OptionsResolver
$resolver): void {
47 $resolver->setDefaults(['error_bubbling' => true]);
53 public function getName() {
54 return 'contact_form';