Quickform_Controller and Smarty

From: Date: Fri, 21 Jan 2005 21:27:25 +0000
Subject: Quickform_Controller and Smarty
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17094@lists.php.net to get a copy of this message
Hi, I've got some single page forms using Quickform and Smarty templates and they work well. I have some multi-page forms with Quickform_Controller using the default renderer and they're fine as well. But I'm having trouble understanding how to make Quickform_Controller work with Smarty templates. Within each page class, within the buildForm method, I have defined the template (a static template) for that page (I've included code below). Then in the ActionDisplay class (in the _renderForm method) I've put the new Smarty object, the accept renderer stuff and the other display information. This seems like the appropriate place, as in my single page Quickforms all of that display code comes after the form is put together. With my mult-page forms this displays and executes the first page properly, but I run into trouble going to the second page. I'm continuing to experiment and figure this out but thought I'd ask the community. Since the Smarty command " $tpl->display('joinform.page1.tpl');" calls for the template name (and the template will vary from page to page), do I have to pass the template name into ActionDisplay? Any insights, or practical examples, would be appreciated. Thank you, Nelson ==== Abstracted Code ==== class Page_New_User extends HTML_QuickForm_Page { function buildForm()
    {
        $this->_formBuilt = true;
// Setup for Smarty template $tpl = "joinform.page1.tpl"; $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); etc. } } .....and then in the ActionDisplay class for the page... class ActionDisplay extends HTML_QuickForm_Action_Display {
    function _renderForm(&$page)
    {
// setup a template object $tpl =& new Smarty; $tpl->template_dir = 'includes/templates'; $tpl->compile_dir = 'includes/templates/compiledtemplates'; ...etc... $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl, true); ... required and error templates... $page->accept($renderer); // assign array with form data $tpl->assign('form', $renderer->toArray()); // capture the array stucture ob_start(); $tpl->assign('static_array', ob_get_contents()); ob_end_clean(); // render and display the template $tpl->display('joinform.page1.tpl');
	//	$form->accept($renderer);    --- yields error
         _________________________________________________
         Nelson GOFORTH 				Lighting for Moving Pictures
         +1.303.322.5042 				http://www.earthnet.net/~ngoforth/film


« previous php.pear.general (#17094) next »