<?php
namespace App\Form\Type;
use App\Entity\Shop;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Regex;
/**
* [Web] 新規店舗登録用フォーム
* @author Kazuyuki Hayashi <kaz@noop.co.jp>
*/
class RegisterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, [
'label' => '店舗名',
'attr' => ['class' => 'text'],
])
->add('assignee', TextType::class, [
'label' => '担当者名',
'attr' => ['class' => 'text'],
])
->add('email', RepeatedType::class, [
'type' => EmailType::class,
'constraints' => [new NotBlank()],
'first_options' => [
'label' => 'メールアドレス',
'attr' => ['class' => 'text']
],
'second_options' => [
'label' => '確認のため再度入力してください',
'attr' => [
'oncopy' => "return false", 'onpaste' => "return false", 'oncontextmenu' => "return false", 'class' => 'text']
],
])
->add('tel', TelType::class, [
'label' => '電話番号',
'attr' => [
'placeholder' => '半角数字のみ(ハイフン不要)',
'class' => 'text'
],
'constraints' => [
new Regex(['message' => '電話番号は半角数字のみで入力してください', 'pattern' => '/^[0-9]+$/'])
]
])
->add('plainPassword', TextType::class, [
'label' => 'パスワード',
'constraints' => [new NotBlank()],
'attr' => ['class' => 'text'],
]);
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Shop::class
]);
}
}