src/Eccube/Form/Type/Admin/TradeLawType.php line 26

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\Admin;
  13. use Eccube\Common\EccubeConfig;
  14. use Eccube\Entity\TradeLaw;
  15. use Eccube\Form\Type\ToggleSwitchType;
  16. use Symfony\Component\Form\AbstractType;
  17. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  18. use Symfony\Component\Form\Extension\Core\Type\TextType;
  19. use Symfony\Component\Form\FormBuilderInterface;
  20. use Symfony\Component\OptionsResolver\OptionsResolver;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. class TradeLawType extends AbstractType
  23. {
  24.     /**
  25.      * @var EccubeConfig
  26.      */
  27.     protected $eccubeConfig;
  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'TextType::class, [
  39.                 'required' => false,
  40.                 'constraints' => [
  41.                     new Assert\Length([
  42.                         'max' => $this->eccubeConfig['eccube_stext_len'],
  43.                     ]),
  44.                 ],
  45.             ])
  46.             ->add('description'TextareaType::class, [
  47.                 'required' => false,
  48.                 'purify_html' => true,
  49.                 'constraints' => [
  50.                     new Assert\Length([
  51.                         'max' => 4000,
  52.                     ]),
  53.                 ],
  54.             ])
  55.             ->add('displayOrderScreen'ToggleSwitchType::class, [
  56.                 'required' => false,
  57.                 'label_on' => '',
  58.                 'label_off' => '',
  59.             ]);
  60.     }
  61.     /**
  62.      * {@inheritdoc}
  63.      */
  64.     public function configureOptions(OptionsResolver $resolver)
  65.     {
  66.         $resolver->setDefaults([
  67.             'data_class' => TradeLaw::class,
  68.         ]);
  69.     }
  70. }