In my controller I got a function which looks like this:
public function newExperienceAction() {
$this->_helper->layout->disableLayout();
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('newExperience', 'html')->initContext();
$id = $this->_getParam('id', null);
$this->form = new Application_Form_Cv();
$this->experience = new Zend_Form_SubForm();
$this->form->addSubForm($this->experience, 'experience');
$rowExperience = new Application_Form_Experience();
$rowExperience->setDisplayGroups('experience');
$this->experience->addSubForm($rowExperience, "experience$id", $id+3);
echo $rowExperience->__toString();
}
When the user press (+) on the form, a new subForm will be displayed.
I’m currently in the process if shaping it into a table. I will have more than one subForm on this form so I need to use DisplayGroups.
In this situation, I believe I have to create a Display group when the form is first created.
Then I need to append the new subForms to the existing display groups.
So the question:
How do I add new subForms to an existing display group?
You can achieve this by simply adding
This causes the sub-form to act like a display group, i.e. its values are wrapped in an array indexed by the sub-form’s name (
experience$idin your case).