src/Form/Type/ScriptType.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Form\Type;
  3. use Symfony\Component\Form\Extension\Core\Type\TextType;
  4. use Symfony\Component\Form\FormInterface;
  5. use Symfony\Component\Form\FormView;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. class ScriptType extends TextType
  8. {
  9.     /**
  10.      * {@inheritdoc}
  11.      */
  12.     public function configureOptions(OptionsResolver $resolver)
  13.     {
  14.         parent::configureOptions($resolver);
  15.         $resolver->setDefined('template');
  16.         $resolver->setDefaults([
  17.             'label' => false,
  18.             'required' => false,
  19.             'mapped' => false,
  20.             'template' => null,
  21.             'object'    => null
  22.         ]);
  23.     }
  24.     public function buildView(FormView $viewFormInterface $form, array $options)
  25.     {
  26.         parent::buildView($view$form$options);
  27.         $view->vars['template'] = $options['template'];
  28.         $view->vars['object'] = $options['object'];
  29.         $view->vars['label'] = false;
  30.     }
  31.     /**
  32.      * {@inheritdoc}
  33.      */
  34.     public function getName()
  35.     {
  36.         return $this->getBlockPrefix();
  37.     }
  38.     /**
  39.      * {@inheritdoc}
  40.      */
  41.     public function getBlockPrefix()
  42.     {
  43.         return 'script';
  44.     }
  45. }