app/Plugin/PiaContact/Form/Type/FormRecruitType.php line 19

Open in your IDE?
  1. <?php
  2. namespace Plugin\PiaContact\Form\Type;
  3. use Eccube\Form\Type\AddressType;
  4. use Eccube\Form\Type\KanaType;
  5. use Eccube\Form\Type\NameType;
  6. use Eccube\Form\Type\Master\SexType;
  7. use Eccube\Form\Type\PhoneNumberType;
  8. use Eccube\Form\Type\PostalType;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\DateType;
  11. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  14. use Symfony\Component\Form\FormBuilderInterface;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. class FormRecruitType extends AbstractType
  17. {
  18.     /**
  19.      * {@inheritdoc}
  20.      */
  21.     public function buildForm(FormBuilderInterface $builder, array $options)
  22.     {
  23.         $builder
  24.             ->add('name'NameType::class, [
  25.                 'required' => true,
  26.             ])
  27.             ->add('kana'KanaType::class, [
  28.                 'required' => true,
  29.             ])
  30.             ->add('birth'DateType::class, [
  31.                 'label' => '生年月日',
  32.                 'required' => true,
  33.                 'input' => 'datetime',
  34.                 'widget' => 'single_text',
  35.                 'format' => 'yyyy-MM-dd',
  36.                 'html5' => true,
  37.                 'attr' => [
  38.                     'type' => 'date',
  39.                     'max' => date('Y-m-d'),
  40.                 ],
  41.                 'constraints' => [
  42.                     new Assert\NotBlank(['message' => '生年月日を入力してください。']),
  43.                     new Assert\LessThanOrEqual([
  44.                         'value' => 'today',
  45.                         'message' => '生年月日は今日以前の日付を入力してください。'
  46.                     ]),
  47.                 ],
  48.             ])
  49.             ->add('sex'SexType::class, [
  50.                 'label' => '性別',
  51.                 'required' => false,
  52.             ])
  53.             ->add('address'AddressType::class, [
  54.                 'required' => true,
  55.             ])
  56.             ->add('email'EmailType::class, [
  57.                 'required' => true,
  58.                 'constraints' => [
  59.                     new Assert\NotBlank(['message' => 'メールアドレスを入力してください。']),
  60.                     new Assert\Email(['message' => 'メールアドレスの形式が正しくありません。']),
  61.                 ],
  62.             ])
  63.             ->add('tel'PhoneNumberType::class, [
  64.                 'required' => true,
  65.             ])
  66.             ->add('zip'PostalType::class, [
  67.                 'required' => true,
  68.             ])
  69.             ->add('final_education'TextType::class, [
  70.                 'label' => '最終学歴',
  71.                 'required' => true,
  72.                 'constraints' => [
  73.                     new Assert\NotBlank(['message' => '最終学歴を入力してください。']),
  74.                 ],
  75.             ])
  76.             ->add('graduation_date'TextType::class, [
  77.                 'label' => '卒業年月',
  78.                 'required' => true,
  79.                 'constraints' => [
  80.                     new Assert\NotBlank(['message' => '卒業年月を入力してください。']),
  81.                 ],
  82.             ])
  83.             ->add('free_area'TextareaType::class, [
  84.                 'label' => '自由項目(応募動機・自己PR・ご質問など)',
  85.                 'required' => false,
  86.                 'attr' => [
  87.                     'rows' => 5,
  88.                 ],
  89.             ])
  90.         ;
  91.     }
  92.     /**
  93.      * {@inheritdoc}
  94.      */
  95.     public function getBlockPrefix()
  96.     {
  97.         return 'form_recruit';
  98.     }
  99. }