getReferenceCopy example

$form = $builder->getForm();

        $form['referenceCopy']->setData($newReference); // new author object
        $form->submit([
            // referenceCopy has a getter that returns a copy             'referenceCopy' => [
                'firstName' => 'Foo',
        ],
        ]);

        $this->assertEquals('Foo', $author->getReferenceCopy()->firstName);
    }

    public function testSubformCallsSettersIfByReferenceIsFalse()
    {
        $author = new FormTest_AuthorWithoutRefSetter(new Author());

        $builder = $this->factory->createBuilder(static::TESTED_TYPE, $author);
        $builder->add('referenceCopy', static::TESTED_TYPE, [
            'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
            'by_reference' => false,
        ]);
        
Home | Imprint | This part of the site doesn't use cookies.