<?php
namespace Plugin\PiaContact\Form\Type;
use Eccube\Form\Type\AddressType;
use Eccube\Form\Type\KanaType;
use Eccube\Form\Type\NameType;
use Eccube\Form\Type\PostalType;
use Eccube\Form\Type\PhoneNumberType;
use Eccube\Form\Type\Master\PrefType;
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\FileType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* 査定申込フォーム
*/
class FormAppraisalType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('kana', KanaType::class, [
'required' => true,
])
->add('name', NameType::class, [
'required' => true,
])
->add('zip', PostalType::class, [
'required' => true,
])
->add('address', AddressType::class, [
'required' => true,
])
->add('tel', PhoneNumberType::class, [
'required' => true,
])
->add('email', EmailType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
new Assert\Email(),
],
])
->add('contact', ChoiceType::class, [
'label' => 'ご連絡方法',
'choices' => [
'TEL' => '1',
'メール' => '2',
],
'expanded' => true,
'multiple' => false,
'required' => false,
'placeholder' => false,
])
->add('receiving', ChoiceType::class, [
'label' => 'お受取方法',
'choices' => [
'ご配送' => '1',
'ご来店' => '2',
],
'expanded' => true,
'multiple' => false,
'required' => false,
'placeholder' => false,
])
->add('contents', TextareaType::class, [
'label' => 'メッセージ',
'required' => false,
'attr' => [
'rows' => 5,
'placeholder' => 'ご質問やご要望がございましたら、こちらにご記入ください。',
],
]);
// 商品項目(5個)
for ($i = 1; $i <= 5; $i++) {
$builder
->add("item0{$i}_name", TextType::class, [
'label' => "申込コイン{$i}(名)",
'required' => false,
'attr' => [
'placeholder' => '2021 イギリス クイーンズビースト£1000 1kg金貨',
'class' => 'form-control',
],
])
->add("item0{$i}_num", IntegerType::class, [
'label' => "申込コイン{$i}(数量)",
'required' => false,
'attr' => [
'class' => 'form-control',
'min' => 0,
],
])
->add("item0{$i}_price", IntegerType::class, [
'label' => "申込コイン{$i}(価格(円))",
'required' => false,
'attr' => [
'class' => 'form-control',
'min' => 0,
'placeholder' => '価格を円で入力してください',
],
])
->add("item0{$i}_img", FileType::class, [
'label' => "申込コイン{$i}(画像)",
'mapped' => false,
'required' => false,
'constraints' => [
new Assert\File([
'maxSize' => '10M',
'maxSizeMessage' => '画像ファイルは10M以下でアップロードしてください。',
'mimeTypes' => [
'image/jpeg',
'image/png',
'image/gif',
],
'mimeTypesMessage' => 'JPEG、PNG、GIF形式の画像ファイルをアップロードしてください。',
]),
],
]);
}
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'form_appraisal';
}
}