app/Plugin/PiaReservation/Form/Type/PiaReservationType.php line 15

Open in your IDE?
  1. <?php
  2. namespace Plugin\PiaReservation\Form\Type;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\TextType;
  5. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\TelType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. class PiaReservationType extends AbstractType
  13. {
  14.     /**
  15.      * {@inheritdoc}
  16.      */
  17.     public function buildForm(FormBuilderInterface $builder, array $options)
  18.     {
  19.         $builder
  20.             ->add('hope_date01'TextType::class, [
  21.                 'label' => '第1希望日',
  22.                 'required' => true,
  23.                 'attr' => [
  24.                     'class' => 'form-control',
  25.                     'placeholder' => 'YYYY-MM-DD',
  26.                     'readonly' => true
  27.                 ],
  28.                 'constraints' => [
  29.                     new Assert\NotBlank(['message' => '第1希望日を選択してください。'])
  30.                 ]
  31.             ])
  32.             ->add('hope_time01'ChoiceType::class, [
  33.                 'label' => '第1希望時間',
  34.                 'required' => false,
  35.                 'choices' => [
  36.                     '10:00' => '10:00',
  37.                     '10:30' => '10:30',
  38.                     '11:00' => '11:00',
  39.                     '11:30' => '11:30',
  40.                     '12:00' => '12:00',
  41.                     '12:30' => '12:30',
  42.                     '13:00' => '13:00',
  43.                     '13:30' => '13:30',
  44.                     '14:00' => '14:00',
  45.                     '14:30' => '14:30',
  46.                     '15:00' => '15:00',
  47.                     '15:30' => '15:30',
  48.                     '16:00' => '16:00',
  49.                     '16:30' => '16:30',
  50.                     '17:00' => '17:00',
  51.                 ],
  52.                 'placeholder' => '時間を選択してください',
  53.                 'attr' => [
  54.                     'class' => 'form-control'
  55.                 ]
  56.             ])
  57.             ->add('hope_date02'TextType::class, [
  58.                 'label' => '第2希望日',
  59.                 'required' => false,
  60.                 'attr' => [
  61.                     'class' => 'form-control',
  62.                     'placeholder' => 'YYYY-MM-DD',
  63.                     'readonly' => true
  64.                 ]
  65.             ])
  66.             ->add('hope_time02'ChoiceType::class, [
  67.                 'label' => '第2希望時間',
  68.                 'required' => false,
  69.                 'choices' => [
  70.                     '10:00' => '10:00',
  71.                     '10:30' => '10:30',
  72.                     '11:00' => '11:00',
  73.                     '11:30' => '11:30',
  74.                     '12:00' => '12:00',
  75.                     '12:30' => '12:30',
  76.                     '13:00' => '13:00',
  77.                     '13:30' => '13:30',
  78.                     '14:00' => '14:00',
  79.                     '14:30' => '14:30',
  80.                     '15:00' => '15:00',
  81.                     '15:30' => '15:30',
  82.                     '16:00' => '16:00',
  83.                     '16:30' => '16:30',
  84.                     '17:00' => '17:00',
  85.                 ],
  86.                 'placeholder' => '時間を選択してください',
  87.                 'attr' => [
  88.                     'class' => 'form-control'
  89.                 ]
  90.             ])
  91.             ->add('hope_date03'TextType::class, [
  92.                 'label' => '第3希望日',
  93.                 'required' => false,
  94.                 'attr' => [
  95.                     'class' => 'form-control',
  96.                     'placeholder' => 'YYYY-MM-DD',
  97.                     'readonly' => true
  98.                 ]
  99.             ])
  100.             ->add('hope_time03'ChoiceType::class, [
  101.                 'label' => '第3希望時間',
  102.                 'required' => false,
  103.                 'choices' => [
  104.                     '10:00' => '10:00',
  105.                     '10:30' => '10:30',
  106.                     '11:00' => '11:00',
  107.                     '11:30' => '11:30',
  108.                     '12:00' => '12:00',
  109.                     '12:30' => '12:30',
  110.                     '13:00' => '13:00',
  111.                     '13:30' => '13:30',
  112.                     '14:00' => '14:00',
  113.                     '14:30' => '14:30',
  114.                     '15:00' => '15:00',
  115.                     '15:30' => '15:30',
  116.                     '16:00' => '16:00',
  117.                     '16:30' => '16:30',
  118.                     '17:00' => '17:00',
  119.                 ],
  120.                 'placeholder' => '時間を選択してください',
  121.                 'attr' => [
  122.                     'class' => 'form-control'
  123.                 ]
  124.             ])
  125.             ->add('reservation_name'TextType::class, [
  126.                 'label' => 'お名前',
  127.                 'required' => true,
  128.                 'attr' => [
  129.                     'class' => 'form-control'
  130.                 ],
  131.                 'constraints' => [
  132.                     new Assert\NotBlank(['message' => 'お名前を入力してください。'])
  133.                 ]
  134.             ])
  135.             ->add('reservation_tel'TelType::class, [
  136.                 'label' => '電話番号',
  137.                 'required' => true,
  138.                 'attr' => [
  139.                     'class' => 'form-control'
  140.                 ],
  141.                 'constraints' => [
  142.                     new Assert\NotBlank(['message' => '電話番号を入力してください。'])
  143.                 ]
  144.             ])
  145.             ->add('reservation_email'EmailType::class, [
  146.                 'label' => 'メールアドレス',
  147.                 'required' => true,
  148.                 'attr' => [
  149.                     'class' => 'form-control'
  150.                 ],
  151.                 'constraints' => [
  152.                     new Assert\NotBlank(['message' => 'メールアドレスを入力してください。']),
  153.                     new Assert\Email(['message' => '正しいメールアドレスを入力してください。'])
  154.                 ]
  155.             ])
  156.             ->add('visitor'ChoiceType::class, [
  157.                 'label' => '来店人数',
  158.                 'required' => false,
  159.                 'choices' => [
  160.                     '1名' => '1名',
  161.                     '2名' => '2名',
  162.                     '3名' => '3名',
  163.                     '4名' => '4名',
  164.                     '5名以上' => '5名以上',
  165.                 ],
  166.                 'placeholder' => '人数を選択してください',
  167.                 'attr' => [
  168.                     'class' => 'form-control'
  169.                 ]
  170.             ])
  171.             ->add('visitor_detail'TextareaType::class, [
  172.                 'label' => '来店者詳細',
  173.                 'required' => false,
  174.                 'attr' => [
  175.                     'class' => 'form-control',
  176.                     'rows' => 3
  177.                 ]
  178.             ])
  179.             ->add('message'TextareaType::class, [
  180.                 'label' => 'ご要望・ご質問',
  181.                 'required' => false,
  182.                 'attr' => [
  183.                     'class' => 'form-control',
  184.                     'rows' => 5
  185.                 ]
  186.             ]);
  187.     }
  188.     /**
  189.      * {@inheritdoc}
  190.      */
  191.     public function configureOptions(OptionsResolver $resolver)
  192.     {
  193.         $resolver->setDefaults([
  194.             'data_class' => null
  195.         ]);
  196.     }
  197.     /**
  198.      * {@inheritdoc}
  199.      */
  200.     public function getBlockPrefix()
  201.     {
  202.         return 'pia_reservation';
  203.     }
  204. }