<?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\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\Validator\Email;
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\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class InquiryType 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('name', TextType::class, [
'required' => true,
'attr' => [
'placeholder' => 'お名前',
],
'constraints' => [
new Assert\NotBlank(),
],
])
->add('kana', TextType::class, [
'required' => false,
'attr' => [
'placeholder' => 'フリガナ',
],
'constraints' => [
new Assert\Regex([
'pattern' => '/^[ァ-ヶヲ-゚ー]+$/u',
'message' => 'form_error.kana_only',
]),
new Assert\Length([
'max' => $this->eccubeConfig['eccube_kana_len'],
]),
],
])
->add('email', EmailType::class, [
'constraints' => [
new Assert\NotBlank(),
new Email(null, null, $this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' : null),
],
])
->add('title', ChoiceType::class, [
'required' => true,
'choices' => [
'-' => null,
'採用について' => '採用について',
'オフィス家具について' => 'オフィス家具について',
'コンサルティングについて' => 'コンサルティングについて',
'その他' => 'その他',
],
'expanded' => false,
'multiple' => false,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('content', TextareaType::class, [
'constraints' => [
new Assert\NotBlank(),
new Assert\Length([
'max' => $this->eccubeConfig['eccube_lltext_len'],
])
],
]);
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'Customize\Entity\Inquiry',
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'inquiry';
}
}