src/Form/Type/RegisterType.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Form\Type;
  3. use App\Entity\Shop;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  7. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  8. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  9. use Symfony\Component\Form\Extension\Core\Type\TelType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. use Symfony\Component\Validator\Constraints\Regex;
  15. /**
  16.  * [Web] 新規店舗登録用フォーム
  17.  * @author Kazuyuki Hayashi <kaz@noop.co.jp>
  18.  */
  19. class RegisterType extends AbstractType
  20. {
  21.     public function buildForm(FormBuilderInterface $builder, array $options)
  22.     {
  23.         $builder
  24.             ->add('name'TextType::class, [
  25.                 'label' => '店舗名',
  26.                 'attr' => ['class' => 'text'],
  27.             ])
  28.             ->add('assignee'TextType::class, [
  29.                 'label' => '担当者名',
  30.                 'attr' => ['class' => 'text'],
  31.             ])
  32.             ->add('email'RepeatedType::class, [
  33.                 'type' => EmailType::class,
  34.                 'constraints' => [new NotBlank()],
  35.                 'first_options' => [
  36.                     'label' => 'メールアドレス',
  37.                     'attr' => ['class' => 'text']
  38.                 ],
  39.                 'second_options' => [
  40.                     'label' => '確認のため再度入力してください',
  41.                     'attr' => [
  42.                         'oncopy' => "return false"'onpaste' => "return false"'oncontextmenu' => "return false"'class' => 'text']
  43.                 ],
  44.             ])
  45.             ->add('tel'TelType::class, [
  46.                 'label' => '電話番号',
  47.                 'attr' => [
  48.                     'placeholder' => '半角数字のみ(ハイフン不要)',
  49.                     'class' => 'text'
  50.                 ],
  51.                 'constraints' => [
  52.                     new Regex(['message' => '電話番号は半角数字のみで入力してください''pattern' => '/^[0-9]+$/'])
  53.                 ]
  54.             ])
  55.             ->add('plainPassword'TextType::class, [
  56.                 'label' => 'パスワード',
  57.                 'constraints' => [new NotBlank()],
  58.                 'attr' => ['class' => 'text'],
  59.             ]);
  60.        ;
  61.     }
  62.     public function configureOptions(OptionsResolver $resolver)
  63.     {
  64.         $resolver->setDefaults([
  65.             'data_class' => Shop::class
  66.         ]);
  67.     }
  68. }