app/Plugin/PiaContact/Form/Type/BulkPurchaseType.php line 15

Open in your IDE?
  1. <?php
  2. namespace Plugin\PiaContact\Form\Type;
  3. use Eccube\Common\EccubeConfig;
  4. use Eccube\Form\Type\NameType;
  5. use Eccube\Form\Type\PhoneNumberType;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  8. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  9. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. class BulkPurchaseType extends AbstractType
  13. {
  14.     /**
  15.      * @var EccubeConfig
  16.      */
  17.     protected $eccubeConfig;
  18.     public function __construct(EccubeConfig $eccubeConfig)
  19.     {
  20.         $this->eccubeConfig $eccubeConfig;
  21.     }
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function buildForm(FormBuilderInterface $builder, array $options)
  26.     {
  27.         $builder
  28.             ->add('material'ChoiceType::class, [
  29.                 'label' => '素材',
  30.                 'choices' => [
  31.                     '金貨' => '1',
  32.                     '銀貨' => '2',
  33.                 ],
  34.                 'expanded' => true,
  35.                 'multiple' => false,
  36.                 'required' => true,
  37.             ])
  38.             ->add('type'ChoiceType::class, [
  39.                 'label' => '種類',
  40.                 'choices' => [
  41.                     'ブリタニア' => '1',
  42.                     'ウィーンフィルハーモニー' => '2',
  43.                     'メープルリーフ' => '3',
  44.                     'カンガルー' => '4',
  45.                 ],
  46.                 'expanded' => true,
  47.                 'multiple' => false,
  48.                 'required' => true,
  49.             ])
  50.             ->add('name'NameType::class, [
  51.                 'required' => true,
  52.             ])
  53.             ->add('email'EmailType::class, [
  54.                 'required' => true,
  55.                 'constraints' => [
  56.                     new Assert\NotBlank(),
  57.                     new Assert\Email(),
  58.                 ],
  59.             ])
  60.             ->add('tel'PhoneNumberType::class, [
  61.                 'required' => true,
  62.             ])
  63.             ->add('weight'ChoiceType::class, [
  64.                 'label' => '重量',
  65.                 'choices' => [
  66.                     '1オンス' => '1',
  67.                     '1/2オンス' => '2',
  68.                     '1/4オンス' => '3',
  69.                     '1/10オンス' => '4',
  70.                     '1/20オンス' => '5',
  71.                     '1/25オンス' => '6',
  72.                     '1グラム' => '7',
  73.                 ],
  74.                 'expanded' => true,
  75.                 'multiple' => false,
  76.                 'required' => true,
  77.             ])
  78.             ->add('num'IntegerType::class, [
  79.                 'label' => '枚数',
  80.                 'required' => true,
  81.                 'attr' => [
  82.                     'placeholder' => '購入枚数',
  83.                     'min' => 1,
  84.                 ],
  85.             ]);
  86.     }
  87.     /**
  88.      * {@inheritdoc}
  89.      */
  90.     public function getBlockPrefix()
  91.     {
  92.         return 'bulk_purchase';
  93.     }
  94. }