-- Joe Theplumber <[EMAIL PROTECTED]> wrote
(on Tuesday, 11 November 2008, 09:02 AM -0800):
> New to some of the Zend_Form pieces and trying to migrate some old code to ZF.
> I was curious whether there is a way to use Zend_Form with html array syntax
> and have Validation and Filtering work.
Use sub forms. Sub forms are for exactly this sort of semantic grouping,
and by default render using array notation. Sub forms may be nested
infinitely deep.
One note, however: form element names must be valid PHP variable names
-- so numeric keys simply will not work currently.
> I would like to have a form like this:
> <form method='post' action='/controller/action'>
> <input type='text' name='node[23][name]'>
> <input type='text' name='node[25][name]'>
> <input type='text' name='node[28][name]'>
> <input type='submit' value='click me'>
> </form>
>
> Seems pretty standard but Zend_Form when created like this wants to flatten it
> out:
> $form=new Zend_Form();
> $form->setAction('/controller/action/')->setMethod('post');
> $main_header=$form->addElement('text','node[23][name]', array('label'=>'Menu
> Header'));
> $main_header=$form->getElement('node[23][name]')
> ->setRequired(true);
> $submit=$form->addElement('submit','submit');
>
> will make node[23][name] into node23name? Is there any way to support this via
> Zend_Form (and ideally on the converse Model object)?
>
> here's something close:
> http://davidcaylor.com/php/building-table-based-forms-in-zend_form
>
> thanks,
>
> jt
>
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/