app/Customize/Form/Type/Front/Contact2Type.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\Component\Form\FormBuilderInterface;
  24. use Symfony\Component\Validator\Constraints as Assert;
  25. use Symfony\Component\Form\Extension\Core\Type\TextType;
  26. use Symfony\Component\Form\Extension\Core\Type\ChoiceType//選択肢
  27. class Contact2Type 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.                 'required' => true,
  50.             ])
  51.             ->add('postal_code'PostalType::class, [
  52.                 'required' => true,
  53.             ])
  54.             ->add('address'AddressType::class, [
  55.                 'required' => true,
  56.             ])
  57.             ->add('phone_number'PhoneNumberType::class, [
  58.                 'required' => true,
  59.             ])
  60.             ->add('email'EmailType::class, [
  61.                 'constraints' => [
  62.                     new Assert\NotBlank(),
  63.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  64.                 ],
  65.             ])
  66.             ->add('contents'TextareaType::class, [
  67.                 'required' => false,
  68.                 'constraints' => [
  69.                     // new Assert\NotBlank(),
  70.                     new Assert\Length([
  71.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  72.                     ])
  73.                 ],
  74.             ])
  75.             // カスタマイズ項目 ここから
  76.            // メニュー1
  77.             ->add('menu_1'ChoiceType::class, [
  78.                 'required' => true,
  79.                 'choices' => [
  80.                     "出品のみ" => "出品のみ",
  81.                     "預け入れ出品" => "預け入れ出品",
  82.                 ],
  83.             ])
  84.             // cpu
  85.             ->add('cpu_head'ChoiceType::class, [
  86.                 'required' => false,
  87.                 'placeholder' => 'CPUモデル',
  88.                 'choices' => [
  89.                     "intel corei3" => "intel corei3",
  90.                     "intel corei5" => "intel corei5",
  91.                     "intel corei7" => "intel corei7",
  92.                     "intel corei9" => "intel corei9",
  93.                     "AMD Ryzen3" => "AMD Ryzen3",
  94.                     "AMD Ryzen5" => "AMD Ryzen5",
  95.                     "AMD Ryzen7" => "AMD Ryzen7",
  96.                     "AMD Ryzen9" => "AMD Ryzen9",
  97.                 ],
  98.             ])
  99.             // 型番(例:i7 13700Fやryzen5 3600XTなど
  100.             ->add('cpu_body'TextType::class, [
  101.                 'required' => false,
  102.                 'constraints' => [
  103.                     // new Assert\NotBlank(),
  104.                     new Assert\Length([
  105.                         'max' => 200,
  106.                     ])
  107.                 ],
  108.             ])
  109.             // cpuクーラー
  110.             ->add('cool'ChoiceType::class, [
  111.                 'required' => false,
  112.                 'placeholder' => 'CPUモデル',
  113.                 'choices' => [
  114.                     "空冷" => "空冷",
  115.                     "水冷" => "水冷",
  116.                 ],
  117.             ])
  118.             // ラジエーター長やメーカーなど
  119.             ->add('cool_body'TextType::class, [
  120.                 'required' => false,
  121.                 'constraints' => [
  122.                     // new Assert\NotBlank(),
  123.                     new Assert\Length([
  124.                         'max' => 200,
  125.                     ])
  126.                 ],
  127.             ])
  128.             // メモリの型番
  129.                         ->add('ram_head'ChoiceType::class, [
  130.                     'required' => false,
  131.                        'placeholder' => 'メモリモデル',
  132.                     'choices' => [
  133.                                "DDR4" => "DDR4",
  134.                                        "DDR5" => "DDR5",
  135.                        ],
  136.                        ])
  137.             // メモリの容量
  138.             ->add('ram_body'ChoiceType::class, [
  139.                 'required' => false,
  140.                 'placeholder' => 'メモリの容量',
  141.                 'choices' => [
  142.                     "4GB" => "4GB",
  143.                     "8GB" => "8GB",
  144.                     "12GB" => "12GB",
  145.                     "16GB" => "16GB",
  146.                     "20GB" => "20GB",
  147.                     "24GB" => "24GB",
  148.                     "28GB" => "28GB",
  149.                     "32GB" => "32GB",
  150.                     "40GB" => "40GB",
  151.                     "64GB" => "64GB",
  152.                     "128GB" => "128GB",
  153.                     "これ以外は空欄へ記入" => "これ以外は空欄へ記入",
  154.                 ],
  155.             ])
  156.             // GB容量、定格周波数など
  157.             ->add('ram_other'TextType::class, [
  158.                 'required' => false,
  159.                 'constraints' => [
  160.                     // new Assert\NotBlank(),
  161.                     new Assert\Length([
  162.                         'max' => 200,
  163.                     ])
  164.                 ],
  165.             ])
  166.             // チップセット等わかる範囲
  167.             ->add('m_b'TextType::class, [
  168.                 'required' => false,
  169.                 'constraints' => [
  170.                     // new Assert\NotBlank(),
  171.                     new Assert\Length([
  172.                         'max' => 200,
  173.                     ])
  174.                 ],
  175.             ])
  176.             // グラフィックボード 型番(text):
  177.             ->add('gpu'TextType::class, [
  178.                 'required' => false,
  179.                 'constraints' => [
  180.                     // new Assert\NotBlank(),
  181.                     new Assert\Length([
  182.                         'max' => 200,
  183.                     ])
  184.                 ],
  185.             ])
  186.             // グラフィックメモリの容量(select):
  187.             ->add('g_ram'ChoiceType::class, [
  188.                 'required' => false,
  189.                 'placeholder' => 'グラフィクメモリの容量',
  190.                 'choices' => [
  191.                     "4GB" => "4GB",
  192.                     "6GB" => "6GB",
  193.                     "8GB" => "8GB",
  194.                     "10GB" => "10GB",
  195.                     "12GB" => "12GB",
  196.                     "16GB" => "16GB",
  197.                     "18GB" => "18GB",
  198.                     "20GB" => "20GB",
  199.                     "22GB" => "22GB",
  200.                     "24GB" => "24GB",
  201.                 ],
  202.             ])
  203.             // ストレージタイプ
  204.             ->add('storage1_type'ChoiceType::class, [
  205.                 'required' => false,
  206.                 'placeholder' => 'ストレージ形式',
  207.                 'choices' => [
  208.                     "SSD" => "SSD",
  209.                     "HDD" => "HDD",
  210.                 ],
  211.             ])
  212.             // ストレージ容量
  213.             ->add('storage1_vol'ChoiceType::class, [
  214.                 'required' => false,
  215.                 'placeholder' => 'ストレージ容量',
  216.                 'choices' => [
  217.                     "120GB以下" => "120GB以下",
  218.                     "200-256GB" => "200-256GB",
  219.                     "400-512GB" => "400-512GB",
  220.                     "850GB-1TB" => "850GB-1TB",
  221.                     "2TB" => "2TB",
  222.                     "4TB" => "4TB",
  223.                     "6TB" => "6TB",
  224.                 ],
  225.             ])
  226.             // ストレージタイプ
  227.             ->add('storage2_type'ChoiceType::class, [
  228.                 'required' => false,
  229.                 'placeholder' => 'ストレージ形式',
  230.                 'choices' => [
  231.                     "SSD" => "SSD",
  232.                     "HDD" => "HDD",
  233.                 ],
  234.             ])
  235.             // ストレージ容量
  236.             ->add('storage2_vol'ChoiceType::class, [
  237.                 'required' => false,
  238.                 'placeholder' => 'ストレージ容量',
  239.                 'choices' => [
  240.                     "120GB以下" => "120GB以下",
  241.                     "200-256GB" => "200-256GB",
  242.                     "400-512GB" => "400-512GB",
  243.                     "850GB-1TB" => "850GB-1TB",
  244.                     "2TB" => "2TB",
  245.                     "4TB" => "4TB",
  246.                     "6TB" => "6TB",
  247.                 ],
  248.             ])
  249.             // ストレージその他
  250.             ->add('storage_other'TextType::class, [
  251.                 'required' => false,
  252.                 'constraints' => [
  253.                     // new Assert\NotBlank(),
  254.                     new Assert\Length([
  255.                         'max' => 200,
  256.                     ])
  257.                 ],
  258.             ])
  259.             // 電源容量
  260.             ->add('psu_vol'ChoiceType::class, [
  261.                 'required' => false,
  262.                 'placeholder' => '電源容量',
  263.                 'choices' => [
  264.                     "500W以下" => "500W以下",
  265.                     "550W" => "550W",
  266.                     "600W" => "600W",
  267.                     "650W" => "650W",
  268.                     "700W" => "700W",
  269.                     "750W" => "750W",
  270.                     "800W" => "800W",
  271.                     "850W" => "850W",
  272.                     "1000-1050W" => "1000-1050W",
  273.                     "1200W" => "1200W",
  274.                     "その他" => "その他",
  275.                 ],
  276.             ])
  277.             // 電源認証
  278.             ->add('psu_auth'ChoiceType::class, [
  279.                 'required' => false,
  280.                 'placeholder' => '認証',
  281.                 'choices' => [
  282.                     "80+Standard" => "80+Standard",
  283.                     "Bronze" => "Bronze",
  284.                     "Silver" => "Silver",
  285.                     "Gold" => "Gold",
  286.                     "Platinum" => "Platinum",
  287.                     "Titan" => "Titan",
  288.                     "わからない・その他" => "わからない・その他",
  289.                 ],
  290.             ])
  291.             // 電源(その他)
  292.             ->add('psu_other'TextType::class, [
  293.                 'required' => false,
  294.                 'constraints' => [
  295.                     // new Assert\NotBlank(),
  296.                     new Assert\Length([
  297.                         'max' => 200,
  298.                     ])
  299.                 ],
  300.             ])
  301.             //PCケース
  302.             ->add('pc_case'TextType::class, [
  303.                 'required' => false,
  304.                 'constraints' => [
  305.                     // new Assert\NotBlank(),
  306.                     new Assert\Length([
  307.                         'max' => 200,
  308.                     ])
  309.                 ],
  310.             ])
  311.             // OS(タイプ)
  312.             ->add('os_type'ChoiceType::class, [
  313.                 'required' => false,
  314.                 'placeholder' => 'OS',
  315.                 'choices' => [
  316.                     "Windows10" => "Windows10",
  317.                     "Windows11" => "Windows11",
  318.                 ],
  319.             ])
  320.             ->add('os_edi'ChoiceType::class, [
  321.                 'required' => false,
  322.                 'placeholder' => 'エディション',
  323.                 'choices' => [
  324.                     "Home 64bit" => "Home 64bit",
  325.                     "Pro 64bit" => "Pro 64bit",
  326.                 ],
  327.             ])
  328.             ->add('os_other'TextType::class, [
  329.                 'required' => false,
  330.                 'constraints' => [
  331.                     // new Assert\NotBlank(),
  332.                     new Assert\Length([
  333.                         'max' => 200,
  334.                     ])
  335.                 ],
  336.             ])
  337.             // ペットの有無(ラジオボタン)
  338.             //->add('pet_1', ChoiceType::class, [
  339.             //    'required' => true,
  340.             //    'choices' => [
  341.             //        "有り" => "有り",
  342.             //        "無し" => "無し",
  343.             //        "職場等で接する" => "職場等で接する",
  344.             //    ],
  345.             //    'expanded' => true,
  346.             //    'multiple' => false,
  347.             //    'constraints' => [
  348.             //        new Assert\NotBlank(),
  349.             //    ],
  350.             //])
  351.             // ペットの種類
  352.             ->add('pet_1'ChoiceType::class, [
  353.                   'required' => true,
  354.                  'choices' => [
  355.                   "無し" => "無し",
  356.                   "有り" => "有り",
  357.         "その他(職業柄等)" => "その他(職業柄等)",
  358.              ],
  359.           ])
  360.             // ペットの種類
  361.             ->add('pet_2'ChoiceType::class, [
  362.                 'required' => false,
  363.                 'placeholder' => '有・その他の場合選択',
  364.                 'choices' => [
  365.                     "犬・猫" => "犬・猫",
  366.                     "鳥類" => "鳥類",
  367.             "爬虫類" => "爬虫類",
  368.                 ],
  369.             ])
  370.             // 喫煙環境
  371.             ->add('smoke'ChoiceType::class, [
  372.                 'required' => true,
  373.                 'choices' => [
  374.                     "なし" => "なし",
  375.                     "あり" => "あり",
  376.                 ],
  377.             ])
  378.             // 希望販売価格
  379.             ->add('price'ChoiceType::class, [
  380.                 'required' => true,
  381.                 'choices' => [
  382.                     "おまかせ" => "おまかせ",
  383.                     "自分で決める" => "自分で決める",
  384.                 ],
  385.             ])
  386.             ->add('hope_price'TextType::class, [
  387.                 'required' => false,
  388.                 'constraints' => [
  389.                     new Assert\Length([
  390.                         'max' => 200,
  391.                     ])
  392.                 ],
  393.             ])
  394.             // 買取同時見積もり(select):しない・する
  395.             ->add('hope_quote'ChoiceType::class, [
  396.                 'required' => true,
  397.                 'choices' => [
  398.                     "しない" => "しない",
  399.                     "する" => "する",
  400.                 ],
  401.             ])
  402.             // ペットの有無(ラジオボタン)
  403.                 ->add('consent'ChoiceType::class, [
  404.                    'required' => true,
  405.                     'choices' => [
  406.                         "同意する" => "同意する",
  407.                     ],
  408.                     'expanded' => true,
  409.                     'multiple' => false,
  410.                     'constraints' => [
  411.                         new Assert\NotBlank(),
  412.                     ],
  413.                 ]);
  414.     }
  415.     /**
  416.      * {@inheritdoc}
  417.      */
  418.     public function getBlockPrefix()
  419.     {
  420.         return 'contact2';
  421.     }
  422. }