app/Customize/Form/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 Customize\Form;
  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\ChoiceType;
  22. use Symfony\Component\Form\Extension\Core\Type\TextType;
  23. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  24. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  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' => false,
  50.             ])
  51.             ->add('name'NameType::class, [
  52.                 'required' => true,
  53.             ])
  54.             ->add('kana'KanaType::class, [
  55.                 'required' => false,
  56.             ])
  57.             ->add('postal_code'PostalType::class, [
  58.                 'required' => false,
  59.             ])
  60.             ->add('address'AddressType::class, [
  61.                 'required' => false,
  62.             ])
  63.             ->add('phone_number'PhoneNumberType::class, [
  64.                 'required' => false,
  65.             ])
  66.             ->add('email'EmailType::class, [
  67.                 'constraints' => [
  68.                     new Assert\NotBlank(),
  69.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  70.                 ],
  71.             ])
  72.             ->add('contact_type'ChoiceType::class, [
  73.                 'label' => 'お問い合わせの種類',
  74.                 'choices' => [
  75.                     '(ご注文前)在庫・納期について' => '(ご注文前)在庫・納期について',
  76.                     '(ご注文後)納期が知りたい' => '(ご注文後)納期が知りたい',
  77.                     '商品ページに表示されている在庫数以上の注文をしたい' => '商品ページに表示されている在庫数以上の注文をしたい',
  78.                     '希望する商品のページが見つからない' => '希望する商品のページが見つからない',
  79.                     'その他' => 'その他',
  80.                 ],
  81.                 'placeholder' => '選択してください',
  82.                 'required' => true,
  83.                 'constraints' => [
  84.                     new Assert\NotBlank(),
  85.                 ],
  86.             ])
  87.             ->add('contents'TextareaType::class, [
  88.                 'constraints' => [
  89.                     new Assert\NotBlank(),
  90.                     new Assert\Length([
  91.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  92.                     ])
  93.                 ],
  94.             ]);
  95.     }
  96.     /**
  97.      * {@inheritdoc}
  98.      */
  99.     public function getBlockPrefix()
  100.     {
  101.         return 'contact';
  102.     }
  103. }