src/Eccube/Form/Type/Front/ContactType.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Form\Type\Front;
  13. use Eccube\Common\EccubeConfig;
  14. use Eccube\Form\Type\AddressType;
  15. use Eccube\Form\Type\KanaType;
  16. use Eccube\Form\Type\NameType;
  17. use Eccube\Form\Type\PhoneNumberType;
  18. use Eccube\Form\Type\PostalType;
  19. use Eccube\Form\Type\RepeatedEmailType;
  20. use Eccube\Form\Validator\Email;
  21. use Symfony\Component\Form\AbstractType;
  22. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  23. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  24. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  25. use Symfony\Component\Form\FormBuilderInterface;
  26. use Symfony\Component\OptionsResolver\OptionsResolver;
  27. use Symfony\Component\Validator\Constraints as Assert;
  28. class ContactType extends AbstractType
  29. {
  30.     /**
  31.      * @var EccubeConfig
  32.      */
  33.     protected $eccubeConfig;
  34.     /**
  35.      * ContactType constructor.
  36.      *
  37.      * @param EccubeConfig $eccubeConfig
  38.      */
  39.     public function __construct(EccubeConfig $eccubeConfig)
  40.     {
  41.         $this->eccubeConfig $eccubeConfig;
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     public function buildForm(FormBuilderInterface $builder, array $options)
  47.     {
  48.         $type $options['type'] ?? 'contact';
  49.         $builder
  50.             ->add('contact_type'HiddenType::class, [
  51.                 'data' => $type,
  52.             ])
  53.             ->add('name'NameType::class, [
  54.                 'required' => true,
  55.             ])
  56.             ->add('kana'KanaType::class, [
  57.                 'required' => true,
  58.             ])
  59.             ->add('postal_code'PostalType::class, [
  60.                 'required' => false,
  61.             ])
  62.             ->add('address'AddressType::class, [
  63.                 'required' => false,
  64.             ])
  65.             ->add('phone_number'PhoneNumberType::class, [
  66.                 'required' => true,
  67.             ])
  68.             ->add('email'RepeatedEmailType::class);
  69.     }
  70.     public function configureOptions(OptionsResolver $resolver)
  71.     {
  72.         $resolver->setDefaults([
  73.             'data_class' => null,
  74.             'type' => 'contact',
  75.         ]);
  76.     }
  77.     public function getBlockPrefix()
  78.     {
  79.         return 'contact';
  80.     }
  81. }