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

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\CheckboxType;
  22. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  23. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  24. use Symfony\Component\Form\Extension\Core\Type\TextType;
  25. use Symfony\Component\Form\FormBuilderInterface;
  26. use Symfony\Component\Validator\Constraints as Assert;
  27. class ContactType extends AbstractType
  28. {
  29.     /**
  30.      * @var EccubeConfig
  31.      */
  32.     protected $eccubeConfig;
  33.     /**
  34.      * ContactType constructor.
  35.      *
  36.      * @param EccubeConfig $eccubeConfig
  37.      */
  38.     public function __construct(EccubeConfig $eccubeConfig)
  39.     {
  40.         $this->eccubeConfig $eccubeConfig;
  41.     }
  42.     /**
  43.      * {@inheritdoc}
  44.      */
  45.     public function buildForm(FormBuilderInterface $builder, array $options)
  46.     {
  47.         $builder
  48.             ->add('company_name'TextType::class, [
  49.                 'required' => true,
  50.                 'constraints' => [
  51.                     new Assert\NotBlank(),
  52.                     new Assert\Length([
  53.                         'max' => $this->eccubeConfig['eccube_stext_len'],
  54.                     ]),
  55.                 ],
  56.             ])
  57.             ->add('company_kana'TextType::class, [
  58.                 'required' => true,
  59.                 'constraints' => [
  60.                     new Assert\NotBlank(),
  61.                     new Assert\Length([
  62.                         'max' => $this->eccubeConfig['eccube_stext_len'],
  63.                     ]),
  64.                     new Assert\Regex([
  65.                         'pattern' => '/^[ァ-ヶヲ-゚ー]+$/u',
  66.                         'message' => 'form_error.kana_only',
  67.                     ]),
  68.                 ],
  69.             ])
  70.             ->add('shop_name'TextType::class, [
  71.                 'required' => false,
  72.                 'constraints' => [
  73. //                    new Assert\NotBlank(),
  74.                     new Assert\Length([
  75.                         'max' => $this->eccubeConfig['eccube_stext_len'],
  76.                     ]),
  77.                 ],
  78.             ])
  79.             ->add('shop_kana'TextType::class, [
  80.                 'required' => false,
  81.                 'constraints' => [
  82. //                    new Assert\NotBlank(),
  83.                     new Assert\Length([
  84.                         'max' => $this->eccubeConfig['eccube_stext_len'],
  85.                     ]),
  86.                     new Assert\Regex([
  87.                         'pattern' => '/^[ァ-ヶヲ-゚ー]+$/u',
  88.                         'message' => 'form_error.kana_only',
  89.                     ]),
  90.                 ],
  91.             ])
  92.             ->add('name'NameType::class, [
  93.                 'required' => true,
  94.             ])
  95.             ->add('kana'KanaType::class, [
  96.                 'required' => true,
  97.             ])
  98.             ->add('postal_code'PostalType::class, [
  99.                 'required' => true,
  100.             ])
  101.             ->add('address'AddressType::class, [
  102.                 'required' => true,
  103.             ])
  104.             ->add('phone_number'PhoneNumberType::class, [
  105.                 'required' => true,
  106.             ])
  107.             ->add('email'EmailType::class, [
  108.                 'constraints' => [
  109.                     new Assert\NotBlank(),
  110.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  111.                 ],
  112.             ])
  113.             ->add('contents'TextareaType::class, [
  114.                 'required' => false,
  115. //                'constraints' => [
  116. //                    new Assert\NotBlank(),
  117. //                ],
  118.             ])
  119.             ->add('user_policy_check'CheckboxType::class, [
  120.                 'required' => true,
  121.                 'label' => null,
  122.                 'mapped' => false,
  123.                 'constraints' => [
  124.                     new Assert\NotBlank(),
  125.                 ],
  126.             ]);
  127.     }
  128.     /**
  129.      * {@inheritdoc}
  130.      */
  131.     public function getBlockPrefix()
  132.     {
  133.         return 'contact';
  134.     }
  135. }