0
 $mon = new Zend_Form_Element_Checkbox('days[mon]');
 $tue = new Zend_Form_Element_Checkbox('tue');

how will I access "days[mon]" element inside view script for the form

$form = new Zend_Form();
$form->addElement($mon);

$form->setDecorator('form',array('ViewScript','viewscript'=>'form.phtml'));

I can easily access "tue" inside form.phtml

   $this->element->tue 

but how to access "days[mon]" ??

1 Answer 1

1

As far as I remember, for this puposes you should use subforms.

For example:

        $mainForm = new Zend_Form();
        $daySubForm = new Zend_Form_SubForm();
        $mon = new Zend_Form_Element_Checkbox('mon');

        $daySubForm->addElement($mon);
        $mainForm->addSubForm($daySubForm, 'days');

        var_dump($mainForm->days->mon);
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.