src/Form/ContactType.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\ContactUs;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. class ContactType extends AbstractType
  10. {
  11. public function buildForm(FormBuilderInterface $builder, array $options): void
  12. {
  13. $builder
  14. ->add('name', null, [
  15. 'row_attr' => [
  16. 'class' => 'col-sm-6',
  17. ],
  18. 'attr' => [
  19. 'placeholder' => 'Enter name',
  20. ],
  21. ])
  22. ->add('email', EmailType::class, [
  23. 'row_attr' => [
  24. 'class' => 'col-sm-6',
  25. ],
  26. 'attr' => [
  27. 'placeholder' => 'Enter email',
  28. ],
  29. ])
  30. ->add('phone', null, [
  31. 'row_attr' => [
  32. 'class' => 'col-sm-6',
  33. ],
  34. 'attr' => [
  35. 'placeholder' => 'Enter phone',
  36. ],
  37. ])
  38. ->add('subject', ChoiceType::class, [
  39. 'choices' => [
  40. 'Select a Subject' => '',
  41. 'web' => 'web',
  42. 'graphic' => 'graphic',
  43. 'video' => 'video',
  44. ],
  45. 'row_attr' => [
  46. 'class' => 'col-sm-6',
  47. ],
  48. ])
  49. ->add('message', null, [
  50. 'attr' => [
  51. 'placeholder' => 'Enter your message',
  52. ],
  53. ])
  54. ->add('captcha', ReCaptchaType::class, [
  55. 'mapped' => false,
  56. 'type' => 'invisible',
  57. ])
  58. ;
  59. }
  60. public function configureOptions(OptionsResolver $resolver): void
  61. {
  62. $resolver->setDefaults([
  63. 'data_class' => ContactUs::class,
  64. ]);
  65. }
  66. }