app/Plugin/ApplyForSampleMagazine42/Form/Type/ApplyType.php line 19

Open in your IDE?
  1. <?php
  2. namespace Plugin\ApplyForSampleMagazine42\Form\Type;
  3. use Eccube\Common\EccubeConfig;
  4. use Eccube\Form\Type\AddressType;
  5. use Eccube\Form\Type\KanaType;
  6. use Eccube\Form\Type\NameType;
  7. use Eccube\Form\Type\PhoneNumberType;
  8. use Eccube\Form\Type\PostalType;
  9. use Eccube\Form\Validator\Email;
  10. use Symfony\Component\Form\AbstractType;
  11. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  12. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. class ApplyType extends AbstractType
  18. {
  19.     /**
  20.      * @var EccubeConfig
  21.      */
  22.     protected $eccubeConfig;
  23.     /**
  24.      * ContactType constructor.
  25.      *
  26.      * @param EccubeConfig $eccubeConfig
  27.      */
  28.     public function __construct(EccubeConfig $eccubeConfig)
  29.     {
  30.         $this->eccubeConfig $eccubeConfig;
  31.     }
  32.     /**
  33.      * {@inheritdoc}
  34.      */
  35.     public function buildForm(FormBuilderInterface $builder, array $options)
  36.     {
  37.         $builder
  38.             ->add('name'NameType::class, [
  39.                 'required' => true,
  40.             ])
  41.             ->add('kana'KanaType::class, [
  42.                 'required' => true,
  43.             ])
  44.             ->add('company_name'TextType::class, [
  45.                 'required' => false,
  46.                 'constraints' => [
  47.                     new Assert\Length([
  48.                         'max' => $this->eccubeConfig['eccube_stext_len'],
  49.                     ]),
  50.                 ],
  51.             ])
  52.             ->add('shipping_type'ChoiceType::class, [
  53.                 'required' => true,
  54.                 'constraints' => [
  55.                     new Assert\NotBlank(),
  56.                 ],
  57.                 'choices' => [
  58.                     '自宅' => 1,
  59.                     '職場' => 2
  60.                 ],
  61.                 'expanded' => true,
  62.             ])
  63.             ->add('postal_code'PostalType::class, [
  64.                 'required' => true,
  65.             ])
  66.             ->add('address'AddressType::class, [
  67.                 'required' => true,
  68.             ])
  69.             ->add('phone_number'PhoneNumberType::class, [
  70.                 'required' => true,
  71.             ])
  72.             ->add('email'EmailType::class, [
  73.                 'constraints' => [
  74.                     new Assert\NotBlank(),
  75.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  76.                 ],
  77.             ])
  78.             ->add('age'ChoiceType::class, [
  79.                 'required' => false,
  80.                 'choices' => [
  81.                     '10代' => 1,
  82.                     '20代' => 2,
  83.                     '30代' => 3,
  84.                     '40代' => 4,
  85.                     '50代' => 5,
  86.                     '60代以上' => 6,
  87.                 ],
  88.                 'placeholder' => false,
  89.                 'expanded' => true,
  90.             ])
  91.             ->add('company_school_name'TextType::class, [
  92.                 'required' => true,
  93.                 'constraints' => [
  94.                     new Assert\NotBlank(),
  95.                 ],
  96.             ])
  97.             ->add('contents1'TextareaType::class, [
  98.                 'required' => false,
  99.                 'constraints' => [
  100.                     new Assert\Length([
  101.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  102.                     ])
  103.                 ],
  104.             ])
  105.             ->add('contents2'TextareaType::class, [
  106.                 'required' => false,
  107.                 'constraints' => [
  108.                     new Assert\Length([
  109.                         'max' => $this->eccubeConfig['eccube_lltext_len'],
  110.                     ])
  111.                 ],
  112.             ])
  113.         ;
  114.     }
  115.     /**
  116.      * {@inheritdoc}
  117.      */
  118.     public function getBlockPrefix()
  119.     {
  120.         return 'apply';
  121.     }
  122. }