<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Form\Type\Front;
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\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\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class ContactType extends AbstractType
{
/**
* @var EccubeConfig
*/
protected $eccubeConfig;
/**
* ContactType constructor.
*
* @param EccubeConfig $eccubeConfig
*/
public function __construct(EccubeConfig $eccubeConfig)
{
$this->eccubeConfig = $eccubeConfig;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('contact_type', ChoiceType::class, [
'choices' => [
'商品について' => '商品について',
'ご注文について' => 'ご注文について',
'ご注文後の内容確認・変更について' => 'ご注文後の内容確認・変更について',
'商品の返品・交換について' => '商品の返品・交換について',
'商品不良(傷・汚れ・パーツ不足)のため返品・交換について' => '商品不良(傷・汚れ・パーツ不足)のため返品・交換について',
'保証・メンテナンスについて' => '保証・メンテナンスについて',
'会員制度・ポイントについて' => '会員制度・ポイントについて',
'その他について' => 'その他について',
],
'placeholder' => '選択してください',
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('order_number', TextType::class, [
'label' => 'ご注文番号',
'required' => false,
])
->add('name', NameType::class, [
'required' => true,
])
->add('kana', KanaType::class, [
'required' => false,
])
->add('postal_code', PostalType::class, [
'required' => false,
])
->add('address', AddressType::class, [
'required' => false,
])
->add('phone_number', PhoneNumberType::class, [
'required' => true,
])
->add('email', EmailType::class, [
'constraints' => [
new Assert\NotBlank(),
new Email(null, null, $this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' : null),
],
])
->add('contents', TextareaType::class, [
'constraints' => [
new Assert\NotBlank(),
new Assert\Length([
'max' => $this->eccubeConfig['eccube_lltext_len'],
])
],
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'contact';
}
}