<?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 Customize\Form;
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\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
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;
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('company_name', TextType::class, [
'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' => false,
])
->add('email', EmailType::class, [
'constraints' => [
new Assert\NotBlank(),
new Email(null, null, $this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' : null),
],
])
->add('contact_type', ChoiceType::class, [
'label' => 'お問い合わせの種類',
'choices' => [
'(ご注文前)在庫・納期について' => '(ご注文前)在庫・納期について',
'(ご注文後)納期が知りたい' => '(ご注文後)納期が知りたい',
'商品ページに表示されている在庫数以上の注文をしたい' => '商品ページに表示されている在庫数以上の注文をしたい',
'希望する商品のページが見つからない' => '希望する商品のページが見つからない',
'その他' => 'その他',
],
'placeholder' => '選択してください',
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('contents', TextareaType::class, [
'constraints' => [
new Assert\NotBlank(),
new Assert\Length([
'max' => $this->eccubeConfig['eccube_lltext_len'],
])
],
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'contact';
}
}