app/Customize/Form/Type/Front/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\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\TextareaType;
  23. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  24. use Symfony\Component\Form\Extension\Core\Type\TextType;
  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('name'NameType::class, [
  49.                 'label' => 'お名前',
  50.                 'required' => true,
  51.             ])
  52.             ->add('kana'KanaType::class, [
  53.                 'label' => 'お名前(フリガナ)',
  54.                 'required' => false,
  55.             ])
  56.             ->add('postal_code'PostalType::class, [
  57.                 'required' => false,
  58.             ])
  59.             ->add('address'AddressType::class, [
  60.                 'label' => '住所',
  61.                 'required' => false,
  62.             ])
  63.             ->add('phone_number'PhoneNumberType::class, [
  64.                 'label' => '電話番号',
  65.                 'required' => false,
  66.             ])
  67.             ->add('email'EmailType::class, [
  68.                 'label' => 'メールアドレス',
  69.             ])
  70.             ->add('contents'TextareaType::class, [
  71.                 'label' => 'お問い合わせ内容',
  72.                 'constraints' => [
  73.                     new Assert\NotBlank(),
  74.                 ],
  75.             ])->add('school'EntityType::class, array(
  76.                 'label' => '学校',
  77.                 'required' => false,
  78.                 'class' => 'Customize\Entity\School',
  79.                 'expanded' => false,
  80.                 'multiple' => false,
  81.                 'choice_label' => 'school_name',
  82.                 'placeholder' => '選択してください',
  83.             ))
  84.             ->add('school_year'TextType::class, array(
  85.                 'label'     => '学年',
  86.                 'required' => false,
  87.             ))
  88.             ->add('school_class'TextType::class, array(
  89.                 'label'     => 'クラス',
  90.                 'required' => false,
  91.             ));
  92.     }
  93.     /**
  94.      * {@inheritdoc}
  95.      */
  96.     public function getBlockPrefix()
  97.     {
  98.         return 'contact';
  99.     }
  100. }