Exemplo n.º 1
0
 /**
  * @dataProvider layoutProvider
  */
 public function testLayout($formOptions, $formItems, $expectedBlocks)
 {
     $formBuilder = $this->factory->createNamedBuilder('test', 'form', null, $formOptions);
     $this->buildForm($formBuilder, $formItems);
     $formView = $formBuilder->getForm()->createView();
     $result = $this->builder->build($formView);
     $expected = $this->getBlocks($expectedBlocks);
     $this->assertEquals($expected, $result->toArray());
 }
Exemplo n.º 2
0
 /**
  * @param \Twig_Environment $env
  * @param array             $context
  * @param FormView          $form
  * @param string            $formVariableName
  *
  * @return array
  */
 public function render(\Twig_Environment $env, $context, FormView $form, $formVariableName = 'form')
 {
     // remember current loader
     $originalLoader = $env->getLoader();
     // replace the loader
     $env->setLoader(new \Twig_Loader_Chain(array($originalLoader, new \Twig_Loader_String())));
     // build blocks
     $builder = new DataBlockBuilder(new TwigTemplateRenderer($env, $context), $formVariableName);
     $result = $builder->build($form);
     // restore the original loader
     $env->setLoader($originalLoader);
     return $result->toArray();
 }