app/Plugin/PiaDocumentRequest/Form/Type/PiaDocumentRequestType.php line 20

Open in your IDE?
  1. <?php
  2. namespace Plugin\PiaDocumentRequest\Form\Type;
  3. use Eccube\Common\EccubeConfig;
  4. use Eccube\Form\Type\AddressType;
  5. use Eccube\Form\Type\KanaType;
  6. use Eccube\Form\Type\NameType;
  7. use Eccube\Form\Type\PhoneNumberType;
  8. use Eccube\Form\Type\PostalType;
  9. use Eccube\Form\Type\Master\SexType;
  10. use Eccube\Form\Validator\Email;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  14. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. class PiaDocumentRequestType extends AbstractType {
  18.   /**
  19.    * @var EccubeConfig
  20.    */
  21.   protected $eccubeConfig;
  22.   /**
  23.    * ContactType constructor.
  24.    *
  25.    * @param EccubeConfig $eccubeConfig
  26.    */
  27.   public function __construct(EccubeConfig $eccubeConfig) {
  28.     $this->eccubeConfig $eccubeConfig;
  29.   }
  30.   public function getHashAbout() {
  31.     $hash = array(
  32.       "弊社出版の本" => "1",
  33.       "他社出版の本" => "2",
  34.       "友人・知人" => "3",
  35.       "YouTube" => "4",
  36.       "新聞・広告" => "5",
  37.       "バナー広告" => "6",
  38.       "Facebook" => "7",
  39.       "インスタグラム" => "8",
  40.       "旧ツイッター" => "9",
  41.     );
  42.     return $hash;
  43.   }
  44.   public function getHashPurpose() {
  45.     $hash = array(
  46.       "資産保全" => "1",
  47.       "投資" => "2",
  48.       "収集" => "3",
  49.       "プレゼント" => "4",
  50.     );
  51.     return $hash;
  52.   }
  53.   public function getHashCoin() {
  54.     $hash = array(
  55.       "モダンコイン" => "1",
  56.       "アンティークコイン" => "2",
  57.       "古代コイン" => "3",
  58.       "地金型コイン" => "4",
  59.     );
  60.     return $hash;
  61.   }
  62.   public function getHashSeminar() {
  63.     $hash = array(
  64.       "する" => "1",
  65.       "しない" => "2",
  66.     );
  67.     return $hash;
  68.   }
  69.   public function getHashShowRoom() {
  70.     $hash = array(
  71.       "興味あり" => "1",
  72.       "興味なし" => "2",
  73.     );
  74.     return $hash;
  75.   }
  76.   public function getHashGold() {
  77.     $hash = array(
  78.       "所有している" => "1",
  79.       "所有している(バーから金貨へ入替え検討中)" => "2",
  80.       "所有している(売却を検討中)" => "3",
  81.       "所有している(売却を相談したい)" => "4",
  82.       "所有していない" => "5",
  83.     );
  84.     return $hash;
  85.   }
  86.   public function getHashAntique() {
  87.     $hash = array(
  88.       "不満" => "1",
  89.       "やや不満" => "2",
  90.       "満足" => "3",
  91.       "所有していない" => "4",
  92.     );
  93.     return $hash;
  94.   }
  95.   public function getHashModern() {
  96.     $hash = array(
  97.       "不満" => "1",
  98.       "やや不満" => "2",
  99.       "満足" => "3",
  100.       "所有していない" => "4",
  101.     );
  102.     return $hash;
  103.   }
  104.   /**
  105.    * {@inheritdoc}
  106.    */
  107.   public function buildForm(FormBuilderInterface $builder, array $options) {
  108.     $htAbout $this->getHashAbout();
  109.     $htPurpose $this->getHashPurpose();
  110.     $htCoin $this->getHashCoin();
  111.     $htSeminar $this->getHashSeminar();
  112.     $htShowRoom $this->getHashShowRoom();
  113.     $htGold $this->getHashGold();
  114.     $htAntique $this->getHashAntique();
  115.     $htModern $this->getHashModern();
  116.     
  117.     $builder
  118.       ->add('name'NameType::class, [
  119.         'required' => true,
  120.       ])
  121.       ->add('kana'KanaType::class, [
  122.         'required' => false,
  123.       ])
  124.       ->add('postal_code'PostalType::class, [
  125.         'required' => true,
  126.         'constraints' => [
  127.           new Assert\NotBlank(),
  128.         ],
  129.       ])
  130.       ->add('address'AddressType::class, [
  131.         'required' => true,
  132.         'constraints' => [
  133.           new Assert\NotBlank(),
  134.         ],
  135.       ])
  136.       ->add('phone_number'PhoneNumberType::class, [
  137.         'required' => true,
  138.         'constraints' => [
  139.           new Assert\NotBlank(),
  140.         ],
  141.       ])
  142.       ->add('email'EmailType::class, [
  143.         'required' => true,
  144.         'constraints' => [
  145.           new Assert\NotBlank(),
  146.           new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  147.         ],
  148.       ])
  149.       ->add('sex'SexType::class, [
  150.         'required' => false,
  151.       ])
  152.       ->add('how_about'ChoiceType::class, [
  153.         'label' => false,
  154.         'choices' => $htAbout,
  155.         'required' => false,
  156.         'expanded' => true,
  157.         'multiple' => true,
  158.         'mapped' => false,
  159.       ])
  160.       ->add('purpose'ChoiceType::class, [
  161.         'label' => false,
  162.         'choices' => $htPurpose,
  163.         'required' => false,
  164.         'expanded' => true,
  165.         'multiple' => true,
  166.         'mapped' => false,
  167.       ])
  168.       ->add('coin'ChoiceType::class, [
  169.         'label' => false,
  170.         'choices' => $htCoin,
  171.         'required' => false,
  172.         'expanded' => true,
  173.         'multiple' => true,
  174.         'mapped' => false,
  175.       ])
  176.       ->add('seminar'ChoiceType::class, [
  177.         'label' => false,
  178.         'choices' => $htSeminar,
  179.         'required' => false,
  180.         'expanded' => true,
  181.         'placeholder' => false,
  182.       ])
  183.       ->add('show_room'ChoiceType::class, [
  184.         'label' => false,
  185.         'choices' => $htShowRoom,
  186.         'required' => false,
  187.         'expanded' => true,
  188.         'placeholder' => false,
  189.       ])
  190.       ->add('gold'ChoiceType::class, [
  191.         'label' => false,
  192.         'choices' => $htGold,
  193.         'required' => false,
  194.         'expanded' => true,
  195.         'placeholder' => false,
  196.       ])
  197.       ->add('antique'ChoiceType::class, [
  198.         'label' => false,
  199.         'choices' => $htAntique,
  200.         'required' => false,
  201.         'expanded' => true,
  202.         'placeholder' => false,
  203.       ])
  204.       ->add('modern'ChoiceType::class, [
  205.         'label' => false,
  206.         'choices' => $htModern,
  207.         'required' => false,
  208.         'expanded' => true,
  209.         'placeholder' => false,
  210.       ])
  211.       ->add('contents'TextareaType::class, [
  212.         'constraints' => [
  213.           new Assert\NotBlank(),
  214.           new Assert\Length([
  215.             'max' => $this->eccubeConfig['eccube_lltext_len'],
  216.             ])
  217.         ],
  218.     ]);
  219.   }
  220.   /**
  221.    * {@inheritdoc}
  222.    */
  223.   public function getBlockPrefix() {
  224.     return 'pia_document_request';
  225.   }
  226. }