src/Form/App/ContactForm.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form\App;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  5. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  6. use Symfony\Component\Form\Extension\Core\Type\TextType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Validator\Constraints\Email;
  10. use Symfony\Component\Validator\Constraints\NotBlank;
  11. class ContactForm extends AbstractType
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function buildForm(FormBuilderInterface $builder, array $options)
  17. {
  18. $builder
  19. ->add('name', TextType::class, array(
  20. 'label' => 'forms.contact.name',
  21. 'constraints' => array(
  22. new NotBlank(),
  23. )
  24. ))
  25. ->add('email', EmailType::class, array(
  26. 'label' => 'forms.contact.email',
  27. 'constraints' => array(
  28. new NotBlank(),
  29. new Email(),
  30. )
  31. ))
  32. ->add('title', TextType::class, array(
  33. 'label' => 'forms.contact.title',
  34. 'constraints' => array(
  35. new NotBlank(),
  36. )
  37. ))
  38. ->add('message', TextareaType::class, array(
  39. 'label' => 'forms.contact.message',
  40. 'constraints' => array(
  41. new NotBlank(),
  42. )
  43. ))
  44. ;
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function configureOptions(OptionsResolver $resolver)
  50. {
  51. $resolver->setDefaults(array(
  52. 'translation_domain' => 'MDLContentBundle',
  53. ));
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function getBlockPrefix(): string
  59. {
  60. return 'mdl_public_bundle_contact';
  61. }
  62. }