<?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\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\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
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('name', NameType::class, [
'label' => 'お名前',
'required' => true,
])
->add('kana', KanaType::class, [
'label' => 'お名前(フリガナ)',
'required' => false,
])
->add('postal_code', PostalType::class, [
'required' => false,
])
->add('address', AddressType::class, [
'label' => '住所',
'required' => false,
])
->add('phone_number', PhoneNumberType::class, [
'label' => '電話番号',
'required' => false,
])
->add('email', EmailType::class, [
'label' => 'メールアドレス',
])
->add('contents', TextareaType::class, [
'label' => 'お問い合わせ内容',
'constraints' => [
new Assert\NotBlank(),
],
])->add('school', EntityType::class, array(
'label' => '学校',
'required' => false,
'class' => 'Customize\Entity\School',
'expanded' => false,
'multiple' => false,
'choice_label' => 'school_name',
'placeholder' => '選択してください',
))
->add('school_year', TextType::class, array(
'label' => '学年',
'required' => false,
))
->add('school_class', TextType::class, array(
'label' => 'クラス',
'required' => false,
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'contact';
}
}