MrMastermindNL, Check out http://github.com/farrelley/Dynamic-Forms-with-Zend-Framework
<http://github.com/farrelley/Dynamic-Forms-with-Zend-Framework>It uses Jquery to clone a subform and add it to the form. It for adding dynamic key values. You can also try this example http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/ <http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/> Shaun J. Farrell Washington, DC On Tue, May 4, 2010 at 5:03 AM, MrMastermindNL <[email protected]>wrote: > > I've come a little further with my issue. I can now make an AJAX call with > JQuery, but it will not return the subform. When I echo a line in my > action, > that is returned, but now I get an "invalid controller specified" in the > return of the AJAX call. Here's my changed code: > > Moved the init() code to the imageformAction: > > public function imageformAction() > { > if ($this->getRequest()->isXmlHttpRequest()) > { > $ajaxContext = $this->_helper->getHelper('AjaxContext'); > $ajaxContext->addActionContext('imageform', > 'html')->initContext(); > > $id = $this->_getParam('id', null); > $this->getForm()->addSubForm(new RS_Form_Pimage(), 'pImage'.$id); > } > } > > JQuery javascript: > > function ajaxAddField() > { > $.post("/admin/project/imageform",{"pid": id}, > function(response) > { > var subForm = $(response); > > $("#addBtn-label").prepend(subForm); > }); > } > > I hope someone can help me out here, so I can get the subforms dynamically > into my form. > > Many thanks in advance. > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/add-subform-using-Jquery-and-AJAX-tp2075629p2125198.html > Sent from the Zend Framework mailing list archive at Nabble.com. >
