app/Customize/Form/Type/Front/MailType.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\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\TextType;
  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 Symfony\Component\Form\Extension\Core\Type\FileType;
  27. class MailType 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('inquiry_company_name'TextType::class, [
  49.                 'required' => false,
  50.                 'constraints' => [
  51.                     new Assert\Length([
  52.                         'max' => 128,
  53.                     ]),
  54.                 ],
  55.             ])
  56.             ->add('inquiry_user_name'TextType::class, [
  57.                 'required' => true,
  58.                 'constraints' => [
  59.                     new Assert\Regex([
  60.                         'pattern' => '/^[^\n]+$/u',
  61.                     ]),
  62.                 ],
  63.             ])
  64.             ->add('inquiry_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('inquiry_tel'PhoneNumberType::class, [
  71.                 'required' => false,
  72.             ])
  73.             ->add('inquiry_oh_id'TextType::class, [
  74.                 'required' => false,
  75.             ])
  76.             ->add('contents'TextareaType::class, [
  77.                 'constraints' => [
  78.                     new Assert\NotBlank(),
  79.                 ],
  80.             ])
  81.             ->add('inquiry_file1'FileType::class, [
  82.                 'multiple' => false,
  83.                 'required' => false,
  84.                 'mapped' => false,
  85.                 'constraints' => [
  86.                     new Assert\File([
  87.                         'maxSize' => '100M',
  88.                     ]),
  89.                 ],
  90.             ])
  91.             ->add('inquiry_file2'FileType::class, [
  92.                 'multiple' => false,
  93.                 'required' => false,
  94.                 'mapped' => false,
  95.                 'constraints' => [
  96.                     new Assert\File([
  97.                         'maxSize' => '100M',
  98.                     ]),
  99.                 ],
  100.             ])
  101.             ->add('inquiry_file3'FileType::class, [
  102.                 'multiple' => false,
  103.                 'required' => false,
  104.                 'mapped' => false,
  105.                 'constraints' => [
  106.                     new Assert\File([
  107.                         'maxSize' => '100M',
  108.                     ]),
  109.                 ],
  110.             ]);
  111.     }
  112.     /**
  113.      * {@inheritdoc}
  114.      */
  115.     public function getBlockPrefix()
  116.     {
  117.         return 'contact';
  118.     }
  119. }