Hi Matthew
OK, using your sample form to illustrate my request:-
$form->addElements(array(
'username' => 'text',
'password' => 'password',
'fullname' => 'text',
'email' => 'text',
'address' => 'text',
'postal' => 'text',
'submit' => 'submit',
'cancel' => 'submit'
))
->addDisplayGroup(array('username', 'password'), 'login')
->addDisplayGroup(array('fullname', 'email', 'address',
'postal'), 'demographics')
->addDisplayGroup(array('submit', 'cancel'), 'actions');
Let's say instead you used instances of Zend_Form_Element instead of
strings...
$username = new Zend_Form_Element_Text('username');
$password = new Zend_Form_Element_Password('password');
$fullname = new Zend_Form_Element_Text('fullname');
... etc.
You can't do this:-
->addDisplayGroup(array($username, $password), 'login')
...but I think there should be no difference - across the component
you should be able to use either a string id of an element or the
element itself when referring to methods that utilise one or more form
elements. Similar to Zend_Acl...
With regards to the addFormGroup functionality, I requested it simply
because I can't see how you could ever sub-class a Form Group? It
appears that it's hard-coded into the logic to add a display group.
Allowing an 'addDisplayGroup' with an existing Zend_Form_DisplayGroup
(or subclass) as the first method instead of an array would allow me
to experiment with behaviours of the group and also free up the way I
create forms.
I can probably overcome these issues by having the display group have
knowledge of its parent form, but will need to do some significant
refactoring to do so.
What is the use case for you? E.g., why do you want to instantiate
display groups separately and add concrete elements to them instead of
using addDisplayGroup and passing the element names? What problem does
it solve? (Just gathering information here for the decision making
process.)
--
Simon Mundy | Director | PEPTOLAB
""" " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654
4124
http://www.peptolab.com