I have below codes
foreach ($this->getChitsInstallment() as $key => $installment) {
$checkElement = new Zend_Form_Element_Checkbox("installment[]");
$checkElement->setAttrib('id', 'installment_'.$key)->setDecorators($decorators->elementDecorators);
$this->addElement($checkElement);
$checkElements[] = $checkElement->getName();
$textElement = new Zend_Form_Element_Text("installmentvalue[$key]");
$textElement->setAttrib('readonly', 'true')->setAttrib('class', 'inp-form');
$textElement->setAttrib('id', 'text_'.$key)->setDecorators($decorators->elementDecorators);
$textElement->setValue($installment);
$textElement->setLabel("Installment $key: ");
$this->addElement($textElement);
$textElements[] = $textElement->getName();
}
I want an output like
<input type="checkbox" name="installment[]" id="installment_1" />
<input type="checkbox" name="installment[]" id="installment_2" />
<input type="checkbox" name="installment[]" id="installment_3" />
In view i just call <?php echo $this->form ?>
Only
Pls give me a solution for this
Regards Nisanth
You'll want to use Zend_Form_Element_MultiCheckbox
instead:
$element = new Zend_Form_Element_MultiCheckbox('installment');
foreach ($this->getChitsInstallment() as $key => $installment) {
$element->addMultiOption($installment, "Installment $key: ");
}
$this->addElement($element);