Have you tried:
$foo = new Zend_Form_SubForm();
$foo->setElementsBelongTo('foo')
->setElements(array(
'bar' => 'text',
'baz' => 'text'
));
echo $foo;
which results in HTML something like:
<input type="text" name="foo[bar]" id="foo.bar" value="" />
<input type="text" name="foo[baz]" id="foo.baz" value="" />
via
From the manual:
Zend_Form::setIsArray($flag): By setting the flag TRUE, you can indicate that an entire form should be treated as an array. By default, the form's name will be used as the name of the array, unless setElementsBelongTo() has been called. If the form has no specified name, or if setElementsBelongTo() has not been set, this flag will be ignored (as there is no array name to which the elements may belong).
You may determine if a form is being treated as an array using the isArray() accessor.
Zend_Form::setElementsBelongTo($array): Using this method, you can specify the name of an array to which all elements of the form belong. You can determine the name using the getElementsBelongTo() accessor.