I've seen other threads and bug reports to do with the belongsTo property of an Zend_Element but nothing that relates directly to what i'm experiencing..
Here is my (simplified) Zend_Form:
Which is fine and the elements render like so:Code:$form = new Zend_Form(); $form->addElement('text', 'fname', array('belongsTo' => 'user')); $form->addElement('text', 'sname', array('belongsTo' => 'user'));
...which is exactly what i want.Code:<input type="text" name="user[fname]" /> <input type="text" name="user[sname]" />
However, when the form is submitted, the element values are only accessible if you call
NOT, if you call...Code:$form->getValue('fname') or $form->getValue('sname')
What i'm expecting to see when you call $form->getValues('user') is an array of the values. The array of values is clearly visible if you callCode:$form->getValue('user');
If this is the expected behaviour, then whats the point of putting them in an array? Because there would be no distinction between "user[fname]" and "client[fname]" - in fact adding another element with name "fname", even though it belongs to another item, would overwrite the previous.Code:$form->getValues();
I've tried adding a sub form which does result in what i want, but that way all the sub-form elements get rendered together, what i really want is to lay the 'array' elements in random places, like this...
Code:<input type="text" name="user[fname]" /> <input type="text" name="some-other-field" /> <input type="text" name="some-other-field2" /> <input type="text" name="user[sname]" /> <input type="text" name="another-field-too" />