src/Eccube/Form/Type/Front/ContactType.php line 29

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of EC-CUBE
  4. *
  5. * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6. *
  7. * http://www.ec-cube.co.jp/
  8. *
  9. * For the full copyright and license information, please view the LICENSE
  10. * file that was distributed with this source code.
  11. */
  12. namespace Eccube\Form\Type\Front;
  13. use Eccube\Common\EccubeConfig;
  14. use Eccube\Form\Type\AddressType;
  15. use Eccube\Form\Type\KanaType;
  16. use Eccube\Form\Type\NameType;
  17. use Eccube\Form\Type\PhoneNumberType;
  18. use Eccube\Form\Type\PostalType;
  19. use Eccube\Form\Validator\Email;
  20. use Symfony\Component\Form\AbstractType;
  21. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  22. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  23. use Symfony\Component\Form\FormBuilderInterface;
  24. use Symfony\Component\Validator\Constraints as Assert;
  25. class ContactType extends AbstractType
  26. {
  27. /**
  28. * @var EccubeConfig
  29. */
  30. protected $eccubeConfig;
  31. /**
  32. * ContactType constructor.
  33. *
  34. * @param EccubeConfig $eccubeConfig
  35. */
  36. public function __construct(EccubeConfig $eccubeConfig)
  37. {
  38. $this->eccubeConfig = $eccubeConfig;
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function buildForm(FormBuilderInterface $builder, array $options)
  44. {
  45. $builder
  46. ->add('name', NameType::class, [
  47. 'required' => true,
  48. ])
  49. ->add('kana', KanaType::class, [
  50. 'required' => false,
  51. ])
  52. ->add('postal_code', PostalType::class, [
  53. 'required' => false,
  54. ])
  55. ->add('address', AddressType::class, [
  56. 'required' => false,
  57. ])
  58. ->add('phone_number', PhoneNumberType::class, [
  59. 'required' => false,
  60. ])
  61. ->add('email', EmailType::class, [
  62. 'constraints' => [
  63. new Assert\NotBlank(),
  64. new Email(null, null, $this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' : null),
  65. ],
  66. ])
  67. ->add('contents', TextareaType::class, [
  68. 'constraints' => [
  69. new Assert\NotBlank(),
  70. new Assert\Length([
  71. 'max' => $this->eccubeConfig['eccube_lltext_len'],
  72. ])
  73. ],
  74. ]);
  75. }
  76. /**
  77. * {@inheritdoc}
  78. */
  79. public function getBlockPrefix()
  80. {
  81. return 'contact';
  82. }
  83. }