src/Eccube/Form/Type/Front/ContactType.php line 30

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\CheckboxType;
  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. class ContactType extends AbstractType
  27. {
  28.     /**
  29.      * @var EccubeConfig
  30.      */
  31.     protected $eccubeConfig;
  32.     /**
  33.      * ContactType constructor.
  34.      *
  35.      * @param EccubeConfig $eccubeConfig
  36.      */
  37.     public function __construct(EccubeConfig $eccubeConfig)
  38.     {
  39.         $this->eccubeConfig $eccubeConfig;
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function buildForm(FormBuilderInterface $builder, array $options)
  45.     {
  46.         $builder
  47.             ->add('name'NameType::class, [
  48.                 'required' => true,
  49.             ])
  50.             ->add('kana'KanaType::class, [
  51.                 'required' => true,
  52.             ])
  53.             ->add('postal_code'PostalType::class, [
  54.                 'required' => true,
  55.             ])
  56.             ->add('address'AddressType::class, [
  57.                 'required' => true,
  58.             ])
  59.             ->add('phone_number'PhoneNumberType::class, [
  60.                 'required' => false,
  61.             ])
  62.             ->add('email'EmailType::class, [
  63.                 'constraints' => [
  64.                     new Assert\NotBlank(),
  65.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  66.                 ],
  67.             ])
  68.             ->add('contents'TextareaType::class, [
  69.                 'constraints' => [
  70.                     new Assert\NotBlank(),
  71.                 ],
  72.             ])
  73.             ->add('user_policy_check'CheckboxType::class, [
  74.                 'required' => true,
  75.                 'label' => null,
  76.                 'mapped' => false,
  77.                 'constraints' => [
  78.                     new Assert\NotBlank(),
  79.                 ],
  80.             ]);
  81.     }
  82.     /**
  83.      * {@inheritdoc}
  84.      */
  85.     public function getBlockPrefix()
  86.     {
  87.         return 'contact';
  88.     }
  89. }