views:

118

answers:

1

how do i have to nest multicheckboxes so that they are named like this 'foo[]['bar']' .

i've used subforms but they give me naming like this 'foo[bar][]'.

my code:

$sub = new Zend_Form_SubForm('sub');

$wish = new Zend_Form_Element_MultiCheckbox('bar');

$wish

->setMultiOptions($education_direction->getAll())
->setLabel('Wish')    
->setRequired(true);

$sub->addElements(array( $wish ));

$this->addSubForm($sub, 'foo');

A: 

Hi,

i think you are looking for "belongsTo" Option for Zend Form Elements.

If you need somethinge like:

Try:

$this->addElement(
         'text', 'field1', 
            array(
             'label'     => 'field',
             'belongsTo' => 'foo'
        ));
ArneRie
awesome. i've set 'belongsTo' => 'foo[]' and i got the field name as 'foo[]['field1]'. works like a charm. thank you very much :)
neziric