3 namespace Rapsys\BlogBundle\Form
;
5 use Symfony\Component\Form\AbstractType
;
6 use Symfony\Component\Form\FormBuilderInterface
;
7 use Symfony\Component\OptionsResolver\OptionsResolver
;
8 use Symfony\Component\Form\Extension\Core\Type\TextType
;
9 use Symfony\Component\Form\Extension\Core\Type\TextareaType
;
10 use Symfony\Component\Form\Extension\Core\Type\EmailType
;
11 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
12 use Symfony\Component\Validator\Constraints\Email
;
13 use Symfony\Component\Validator\Constraints\NotBlank
;
15 class ContactType
extends AbstractType
{
19 public function buildForm(FormBuilderInterface
$builder, array $options) {
20 return $builder->add('name', TextType
::class, array('attr' => array('placeholder' => 'Your name'), 'constraints' => array(new NotBlank(array("message" => "Please provide your name")))))
21 ->add('subject', TextType
::class, array('attr' => array('placeholder' => 'Subject'), 'constraints' => array(new NotBlank(array("message" => "Please give a Subject")))))
22 ->add('email', EmailType
::class, array('attr' => array('placeholder' => 'Your email address'), 'constraints' => array(new NotBlank(array("message" => "Please provide a valid email")), new Email(array("message" => "Your email doesn't seems to be valid")))))
23 ->add('message', TextareaType
::class, array('attr' => array('placeholder' => 'Your message here', 'cols' => 50, 'rows' => 15), 'constraints' => array(new NotBlank(array("message" => "Please provide a message here")))))
24 ->add('submit', SubmitType
::class, array('label' => 'Send', 'attr' => array('class' => 'submit')));
30 public function setDefaultOptions(OptionsResolver
$resolver) {
31 $resolver->setDefaults(array('error_bubbling' => true));
37 public function getName() {
38 return 'contact_form';