phpian
phpian

Reputation: 909

Requires a check box array using Zend_Form_Element_Checkbox

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?

Upvotes: 4

Views: 3405

Answers (1)

Wouter Dorgelo
Wouter Dorgelo

Reputation: 11978

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

Upvotes: 2

Related Questions