If you add a nested group, this group should also be represented in the
object hierarchy. If you want to add a group that operates on the same
hierarchy level, use merge().
class Entity
{
public $location;
}
class Location
{
public $longitude;
public $latitude;
}
$entity = new Entity();
$entity->location = new Location();
$form = new Form('entity', $entity, $validator);
$locationGroup = new FieldGroup('location');
$locationGroup->add(new TextField('longitude'));
$locationGroup->add(new TextField('latitude'));
$form->add($locationGroup);