app/Customize/Form/Type/InquiryType.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;
  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\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\OptionsResolver\OptionsResolver;
  27. use Symfony\Component\Validator\Constraints as Assert;
  28. class InquiryType extends AbstractType
  29. {
  30.     /**
  31.      * @var EccubeConfig
  32.      */
  33.     protected $eccubeConfig;
  34.     /**
  35.      * ContactType constructor.
  36.      *
  37.      * @param EccubeConfig $eccubeConfig
  38.      */
  39.     public function __construct(EccubeConfig $eccubeConfig)
  40.     {
  41.         $this->eccubeConfig $eccubeConfig;
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     public function buildForm(FormBuilderInterface $builder, array $options)
  47.     {
  48.         $builder
  49.             ->add('name'TextType::class, [
  50.                 'required' => true,
  51.                 'attr' => [
  52.                     'placeholder' => 'お名前',
  53.                 ],
  54.                 'constraints' => [
  55.                     new Assert\NotBlank(),
  56.                 ],
  57.             ])
  58.             ->add('kana'TextType::class, [
  59.                 'required' => false,
  60.                 'attr' => [
  61.                     'placeholder' => 'フリガナ',
  62.                 ],
  63.                 'constraints' => [
  64.                     new Assert\Regex([
  65.                         'pattern' => '/^[ァ-ヶヲ-゚ー]+$/u',
  66.                         'message' => 'form_error.kana_only',
  67.                     ]),
  68.                     new Assert\Length([
  69.                         'max' => $this->eccubeConfig['eccube_kana_len'],
  70.                     ]),
  71.                 ],
  72.             ])
  73.             ->add('email'EmailType::class, [
  74.                 'constraints' => [
  75.                     new Assert\NotBlank(),
  76.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  77.                 ],
  78.             ])
  79.             ->add('title'ChoiceType::class, [
  80.                 'required' => true,
  81.                 'choices' => [
  82.                     '-' => null,
  83.                     '採用について' => '採用について',
  84.                     'オフィス家具について' => 'オフィス家具について',
  85.                     'コンサルティングについて' => 'コンサルティングについて',
  86.                     'その他' => 'その他',
  87.                 ],
  88.                 'expanded' => false,
  89.                 'multiple' => false,
  90.                 'constraints' => [
  91.                     new Assert\NotBlank(),
  92.                 ],
  93.             ])
  94.             ->add('content'TextareaType::class, [
  95.                 'constraints' => [
  96.                     new Assert\NotBlank(),
  97.                     new Assert\Length([
  98.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  99.                     ])
  100.                 ],
  101.             ]);
  102.     }
  103.     
  104.     /**
  105.      * {@inheritdoc}
  106.      */
  107.     public function configureOptions(OptionsResolver $resolver)
  108.     {
  109.         $resolver->setDefaults([
  110.             'data_class' => 'Customize\Entity\Inquiry',
  111.         ]);
  112.     }
  113.     
  114.     /**
  115.      * {@inheritdoc}
  116.      */
  117.     public function getBlockPrefix()
  118.     {
  119.         return 'inquiry';
  120.     }
  121. }