I would like to create a form that allows the user to input any number of values, each in a separate text field using an array notation. The example expected HTML output is:
<dd id="dupa-element">
<input type="text" name="dupa[]" value="">
<input type="text" name="dupa[]" value="">
</dd>
However, I can't seem to find a way to introduce multiple input elements within a single element, using array notation without indices.
Currently, I do this:
$elt1 = new Zend_Form_Element_Text('1');
$elt1->setOptions(array('belongsTo' => 'dupa'));
$elt2 = new Zend_Form_Element_Textarea('2');
$elt2->setOptions(array('belongsTo' => 'dupa'));
While this works, Zend_Form treats these as independent elements (which can have different sets of validators and filters - that's sort of cool) and the resulting HTML is something along these lines:
<dd id="dupa-1-element">
<input type="text" name="dupa[1]" id="dupa-1" value="">
</dd>
<dd id="dupa-2-element">
<input type="text" name="dupa[2]" id="dupa-2" value="">
</dd>
Is there a (preferably simple) way to achieve the indexless array notation I'm after?
Zend_Form
instance can be "magically" modified reflect the client-side reality. If your situation doesn't have that kind of indeterminacy, then I'll just delete my comment. Sorry for the misread. – Byline