<?php
namespace Plugin\PiaDocumentRequest\Form\Type;
use Eccube\Common\EccubeConfig;
use Eccube\Form\Type\AddressType;
use Eccube\Form\Type\KanaType;
use Eccube\Form\Type\NameType;
use Eccube\Form\Type\PhoneNumberType;
use Eccube\Form\Type\PostalType;
use Eccube\Form\Type\Master\SexType;
use Eccube\Form\Validator\Email;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class PiaDocumentRequestType extends AbstractType {
/**
* @var EccubeConfig
*/
protected $eccubeConfig;
/**
* ContactType constructor.
*
* @param EccubeConfig $eccubeConfig
*/
public function __construct(EccubeConfig $eccubeConfig) {
$this->eccubeConfig = $eccubeConfig;
}
public function getHashAbout() {
$hash = array(
"弊社出版の本" => "1",
"他社出版の本" => "2",
"友人・知人" => "3",
"YouTube" => "4",
"新聞・広告" => "5",
"バナー広告" => "6",
"Facebook" => "7",
"インスタグラム" => "8",
"旧ツイッター" => "9",
);
return $hash;
}
public function getHashPurpose() {
$hash = array(
"資産保全" => "1",
"投資" => "2",
"収集" => "3",
"プレゼント" => "4",
);
return $hash;
}
public function getHashCoin() {
$hash = array(
"モダンコイン" => "1",
"アンティークコイン" => "2",
"古代コイン" => "3",
"地金型コイン" => "4",
);
return $hash;
}
public function getHashSeminar() {
$hash = array(
"する" => "1",
"しない" => "2",
);
return $hash;
}
public function getHashShowRoom() {
$hash = array(
"興味あり" => "1",
"興味なし" => "2",
);
return $hash;
}
public function getHashGold() {
$hash = array(
"所有している" => "1",
"所有している(バーから金貨へ入替え検討中)" => "2",
"所有している(売却を検討中)" => "3",
"所有している(売却を相談したい)" => "4",
"所有していない" => "5",
);
return $hash;
}
public function getHashAntique() {
$hash = array(
"不満" => "1",
"やや不満" => "2",
"満足" => "3",
"所有していない" => "4",
);
return $hash;
}
public function getHashModern() {
$hash = array(
"不満" => "1",
"やや不満" => "2",
"満足" => "3",
"所有していない" => "4",
);
return $hash;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options) {
$htAbout = $this->getHashAbout();
$htPurpose = $this->getHashPurpose();
$htCoin = $this->getHashCoin();
$htSeminar = $this->getHashSeminar();
$htShowRoom = $this->getHashShowRoom();
$htGold = $this->getHashGold();
$htAntique = $this->getHashAntique();
$htModern = $this->getHashModern();
$builder
->add('name', NameType::class, [
'required' => true,
])
->add('kana', KanaType::class, [
'required' => false,
])
->add('postal_code', PostalType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('address', AddressType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('phone_number', PhoneNumberType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('email', EmailType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
new Email(null, null, $this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' : null),
],
])
->add('sex', SexType::class, [
'required' => false,
])
->add('how_about', ChoiceType::class, [
'label' => false,
'choices' => $htAbout,
'required' => false,
'expanded' => true,
'multiple' => true,
'mapped' => false,
])
->add('purpose', ChoiceType::class, [
'label' => false,
'choices' => $htPurpose,
'required' => false,
'expanded' => true,
'multiple' => true,
'mapped' => false,
])
->add('coin', ChoiceType::class, [
'label' => false,
'choices' => $htCoin,
'required' => false,
'expanded' => true,
'multiple' => true,
'mapped' => false,
])
->add('seminar', ChoiceType::class, [
'label' => false,
'choices' => $htSeminar,
'required' => false,
'expanded' => true,
'placeholder' => false,
])
->add('show_room', ChoiceType::class, [
'label' => false,
'choices' => $htShowRoom,
'required' => false,
'expanded' => true,
'placeholder' => false,
])
->add('gold', ChoiceType::class, [
'label' => false,
'choices' => $htGold,
'required' => false,
'expanded' => true,
'placeholder' => false,
])
->add('antique', ChoiceType::class, [
'label' => false,
'choices' => $htAntique,
'required' => false,
'expanded' => true,
'placeholder' => false,
])
->add('modern', ChoiceType::class, [
'label' => false,
'choices' => $htModern,
'required' => false,
'expanded' => true,
'placeholder' => false,
])
->add('contents', TextareaType::class, [
'constraints' => [
new Assert\NotBlank(),
new Assert\Length([
'max' => $this->eccubeConfig['eccube_lltext_len'],
])
],
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix() {
return 'pia_document_request';
}
}