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\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. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  26. use Symfony\Component\Form\Extension\Core\Type\TextType;
  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('contact_type'ChoiceType::class, [
  49.                 'choices' => [
  50.                     '商品について' => '商品について',
  51.                     'ご注文について' => 'ご注文について',
  52.                     'ご注文後の内容確認・変更について' => 'ご注文後の内容確認・変更について',
  53.                     '商品の返品・交換について' => '商品の返品・交換について',
  54.                     '商品不良(傷・汚れ・パーツ不足)のため返品・交換について' => '商品不良(傷・汚れ・パーツ不足)のため返品・交換について',
  55.                     '保証・メンテナンスについて' => '保証・メンテナンスについて',
  56.                     '会員制度・ポイントについて' => '会員制度・ポイントについて',
  57.                     'その他について' => 'その他について',
  58.                 ],
  59.                 'placeholder' => '選択してください',
  60.                 'required' => true,
  61.                 'constraints' => [
  62.                     new Assert\NotBlank(),
  63.                 ],
  64.             ])
  65.             ->add('order_number'TextType::class, [
  66.                 'label' => 'ご注文番号',
  67.                 'required' => false,
  68.             ])
  69.             ->add('name'NameType::class, [
  70.                 'required' => true,
  71.             ])
  72.             ->add('kana'KanaType::class, [
  73.                 'required' => false,
  74.             ])
  75.             ->add('postal_code'PostalType::class, [
  76.                 'required' => false,
  77.             ])
  78.             ->add('address'AddressType::class, [
  79.                 'required' => false,
  80.             ])
  81.             ->add('phone_number'PhoneNumberType::class, [
  82.                 'required' => true,
  83.             ])
  84.             ->add('email'EmailType::class, [
  85.                 'constraints' => [
  86.                     new Assert\NotBlank(),
  87.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  88.                 ],
  89.             ])
  90.             ->add('contents'TextareaType::class, [
  91.                 'constraints' => [
  92.                     new Assert\NotBlank(),
  93.                     new Assert\Length([
  94.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  95.                     ])
  96.                 ],
  97.             ]);
  98.     }
  99.     /**
  100.      * {@inheritdoc}
  101.      */
  102.     public function getBlockPrefix()
  103.     {
  104.         return 'contact';
  105.     }
  106. }