Symfony\Component\Form\Extension\DataCollector\FormDataCollector::associateFormWithView PHP 메소드

associateFormWithView() 공개 메소드

public associateFormWithView ( Symfony\Component\Form\FormInterface $form, Symfony\Component\Form\FormView $view )
$form Symfony\Component\Form\FormInterface
$view Symfony\Component\Form\FormView
    public function associateFormWithView(FormInterface $form, FormView $view)
    {
        $this->formsByView[spl_object_hash($view)] = spl_object_hash($form);
    }

Usage Example

예제 #1
0
 public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssociated()
 {
     // don't add $this->childForm to $this->form!
     $this->view->children['child'] = $this->childView;
     // but associate the two
     $this->dataCollector->associateFormWithView($this->childForm, $this->childView);
     $this->dataExtractor->expects($this->at(0))->method('extractConfiguration')->with($this->form)->will($this->returnValue(array('config' => 'foo')));
     $this->dataExtractor->expects($this->at(1))->method('extractConfiguration')->with($this->childForm)->will($this->returnValue(array('config' => 'bar')));
     // explicitly call collectConfiguration(), since $this->childForm is not
     // contained in the form tree
     $this->dataCollector->collectConfiguration($this->form);
     $this->dataCollector->collectConfiguration($this->childForm);
     $this->dataCollector->buildFinalFormTree($this->form, $this->view);
     $this->assertSame(array('forms' => array('name' => array('config' => 'foo', 'children' => array('child' => array('config' => 'bar', 'children' => array())))), 'nb_errors' => 0), $this->dataCollector->getData());
 }