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 Eccube\Form\Type\RepeatedEmailType;
  21. use Symfony\Component\Form\AbstractType;
  22. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  23. use Symfony\Component\Form\Extension\Core\Type\TextType;
  24. use Symfony\Component\Form\FormBuilderInterface;
  25. use Symfony\Component\Validator\Constraints as Assert;
  26. use Customize\Form\ContactNameType;
  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('name'TextType::class, [
  49.                 'required' => true,
  50.                 'constraints' => [
  51.                     new Assert\Length([
  52.                         'max' => $this->eccubeConfig['eccube_name_len'],
  53.                     ]),
  54.                     new Assert\Regex([
  55.                         'pattern' => '/^[^\s ]+$/u',
  56.                         'message' => 'form_error.not_contain_spaces',
  57.                     ]),
  58.                     new Assert\NotBlank(),
  59.                 ],
  60.             ])
  61.             ->add('kana'KanaType::class, [
  62.                 'required' => false,
  63.             ])
  64.             ->add('postal_code'PostalType::class, [
  65.                 'required' => true,
  66.             ])
  67.             ->add('address'AddressType::class, [
  68.                 'required' => true,
  69.             ])
  70.             ->add('phone_number'PhoneNumberType::class, [
  71.                 'required' => false,
  72.             ])
  73.             ->add('email'RepeatedEmailType::class, [
  74.                 'constraints' => [
  75.                     new Assert\NotBlank(),
  76.                     new Email(['strict' => $this->eccubeConfig['eccube_rfc_email_check']]),
  77.                 ],
  78.             ])
  79.             ->add('contents'TextareaType::class, [
  80.                 'required' => false,
  81. //                'constraints' => [
  82. //                    new Assert\NotBlank(),
  83. //                ],
  84.             ]);
  85.     }
  86.     /**
  87.      * {@inheritdoc}
  88.      */
  89.     public function getBlockPrefix()
  90.     {
  91.         return 'contact';
  92.     }
  93. }