<?php
namespace Plugin\PiaContact\Form\Type;
use Eccube\Common\EccubeConfig;
use Eccube\Form\Type\NameType;
use Eccube\Form\Type\PhoneNumberType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class BulkPurchaseType extends AbstractType
{
/**
* @var EccubeConfig
*/
protected $eccubeConfig;
public function __construct(EccubeConfig $eccubeConfig)
{
$this->eccubeConfig = $eccubeConfig;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('material', ChoiceType::class, [
'label' => '素材',
'choices' => [
'金貨' => '1',
'銀貨' => '2',
],
'expanded' => true,
'multiple' => false,
'required' => true,
])
->add('type', ChoiceType::class, [
'label' => '種類',
'choices' => [
'ブリタニア' => '1',
'ウィーンフィルハーモニー' => '2',
'メープルリーフ' => '3',
'カンガルー' => '4',
],
'expanded' => true,
'multiple' => false,
'required' => true,
])
->add('name', NameType::class, [
'required' => true,
])
->add('email', EmailType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
new Assert\Email(),
],
])
->add('tel', PhoneNumberType::class, [
'required' => true,
])
->add('weight', ChoiceType::class, [
'label' => '重量',
'choices' => [
'1オンス' => '1',
'1/2オンス' => '2',
'1/4オンス' => '3',
'1/10オンス' => '4',
'1/20オンス' => '5',
'1/25オンス' => '6',
'1グラム' => '7',
],
'expanded' => true,
'multiple' => false,
'required' => true,
])
->add('num', IntegerType::class, [
'label' => '枚数',
'required' => true,
'attr' => [
'placeholder' => '購入枚数',
'min' => 1,
],
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'bulk_purchase';
}
}