-- Julien Huang <[EMAIL PROTECTED]> wrote
(on Thursday, 13 November 2008, 04:38 PM +0100):
> Hello,
> 
> I'm currently using Zend_Form, and can't use square brackets in my
> form elements' name. I've looked at the code, and it seems that the
> method "setName" (by filterName) in Zend_Form_Element removes the
> square brackets, why ? Moreover, there's an option in filterName to
> allow square brackets.

You have several options. First, you can declare the element an array: 
    
    $element->setIsArray(true);

Second, you can use subforms to group related items -- this will create
array notation by default.

In your example, declare the MultiCheckbox as an array.


> Example :
> require_once 'Zend/Form.php';
> $f = new Zend_Form;
> $e = $f->createElement('multiCheckbox', 'question[42]');
> $e->setMultiOptions(array(
>       'Checkbox 1',
>       'Checkbox 2',
>       'Checkbox 3',
> ));
> $f->addElement($e);
> die($f)
> 
> I got input elements like this :
> <input type="checkbox" value="0" name="cb42[]"/>
> <input type="checkbox" value="1" name="cb42[]"/>
> <input type="checkbox" value="2" name="cb42[]"/>
> 
> 
> Instead of :
> <input type="checkbox" value="0" name="cb[42][]"/>
> <input type="checkbox" value="1" name="cb[42][]"/>
> <input type="checkbox" value="2" name="cb[42][]"/>
> 
> How can I achieve this ?
> 
> -- 
> Julien Huang
> 

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to