app/Customize/Form/Type/Front/ContactType.php line 32

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\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\TextType;
  22. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  23. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  24. use Symfony\Component\Form\FormBuilderInterface;
  25. use Symfony\Component\Validator\Constraints as Assert;
  26. //use 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('name'NameType::class, [
  49.                 'required' => true,
  50.             ])
  51.            /* ->add('kana', KanaType::class, [
  52.                 'required' => false,
  53.             ])
  54.            */
  55.             ->add('postal_code'PostalType::class, [
  56.                 'required' => false,
  57.             ])
  58.             ->add('address'AddressType::class, [
  59.                 'required' => false,
  60.             ])
  61.             ->add('phone_number'PhoneNumberType::class, [
  62.                 'required' => false,
  63.             ])
  64.             ->add('email'EmailType::class, [
  65.                 'constraints' => [
  66.                     new Assert\NotBlank(),
  67.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  68.                 ],
  69.             ])
  70.             ->add('contents'TextareaType::class, [
  71.                 'constraints' => [
  72.                     new Assert\NotBlank(),
  73.                     new Assert\Length([
  74.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  75.                     ])
  76.                 ],
  77.             ])
  78.             //オーダー番号を追加
  79.             ->add('order_number'TextType::class, [
  80.                 'label' => 'オーダー番号',
  81.                 'required' => false,
  82.                 'attr' => [
  83.                     'placeholder' => 'オーダー番号を入力してください',
  84.                 ],
  85.             ]);
  86.     }
  87.     /**
  88.      * {@inheritdoc}
  89.      */
  90.     public function getBlockPrefix()
  91.     {
  92.         return 'contact';
  93.     }
  94. }