Contrary to added groups, merged groups operate on the same object as
the group they are merged into.
class Entity
{
public $longitude;
public $latitude;
}
$entity = new Entity();
$form = new Form('entity', $entity, $validator);
$locationGroup = new FieldGroup('location');
$locationGroup->add(new TextField('longitude'));
$locationGroup->add(new TextField('latitude'));
$form->merge($locationGroup);
public merge ( |
||
$group |
public function testMergeThrowsExceptionIfOtherGroupAlreadyBound() { $group1 = new FieldGroup('author'); $group2 = new FieldGroup('publisher'); $group2->add($this->createMockField('firstName')); $group2->bind(array('firstName' => 'Bernhard')); $this->setExpectedException('Symfony\\Component\\Form\\Exception\\AlreadyBoundException'); $group1->merge($group2); }