Requires a check box array using Zend_Form_Element

2019-06-26 18:06发布

问题:

I need an array of check-box that should look like as following:

<input type="checkbox" name="myname[]" >

Currently I am using

new Zend_Form_Element_Checkbox('myname[]');

but it doesn't show the array in html control. It draw this as

<input type="checkbox" name="myname">

AnySolution?

回答1:

<?php
$myname = new Zend_Form_Element_Checkbox('myname');
$myname->setLabel('This is my label')
       ->setRequired(true)
       ->addMultiOptions(array('myname' => true));