1

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

1
  • You have not explained what's wrong or what error you get. Commented Oct 24, 2011 at 15:19

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.