Esempio n. 1
0
 /**
  * Adds a CSRF field to the root form view.
  *
  * @param FormView      $view The form view
  * @param FormInterface $form The form
  */
 public function buildViewBottomUp(FormView $view, FormInterface $form)
 {
     if (!$view->hasParent() && !$form->getAttribute('single_control') && $form->hasAttribute('csrf_field_name')) {
         $name = $form->getAttribute('csrf_field_name');
         $csrfProvider = $form->getAttribute('csrf_provider');
         $intention = $form->getAttribute('csrf_intention');
         $factory = $form->getAttribute('csrf_factory');
         $data = $csrfProvider->generateCsrfToken($intention);
         $csrfForm = $factory->createNamed('hidden', $name, $data, array('property_path' => false));
         $view->addChild($csrfForm->createView($view));
     }
 }
 public function testgetChildFormView()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $pool = new Pool($container, 'title', 'logo.png');
     $helper = new AdminHelper($pool);
     $formView = new FormView('test');
     $formView->set('id', 'test');
     $child = new FormView('test');
     $child->set('id', 'test_elementId');
     $formView->addChild($child);
     $this->assertNull($helper->getChildFormView($formView, 'foo'));
     $this->isInstanceOf('Symfony\\Component\\Form\\FormView', $helper->getChildFormView($formView, 'test_elementId'));
 }