template-based renderers with QuickForm_Controller?

From: Date: Tue, 06 Apr 2004 16:15:41 +0000
Subject: template-based renderers with QuickForm_Controller?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11670@lists.php.net to get a copy of this message
Hello, I was using QuickForm for a while I believed to have a good grip on it and now I am trying to build wizard with templated pages using HTML_QuickForm_Controller. I am totally puzzled by short info on this topic from PEAR Manual: http://pear.php.net/manual/en/package.html.html-quickform-controller.faq .php <http://pear.php.net/manual/en/package.html.html-quickform-controller.fa q.php> (Section "How to use template-based renderers?"). Is any one knows about more descriptive sources of information on this? I tried to follow Manual advice and changed example file given with PEAR distribution (HTML_QuickForm_Controller: Wizard) but get totally bizarre results. I see totally functional form, template is loaded, styling is in place but page elements are not placed in right template spots! I am using Smarty template as a template engine. Thank you in advance if someone will be able to point out in right direction Maxim Volkov P.S. Below you can see the actual code excerpt from my experimental file. What could be wrong in this piece? Here is the header part which, how I understand, should override _renderForm() class method. ------------------------------------------------------------------------ ------------------------------------------------------------------------ -------------------------- <?php require_once 'HTML/QuickForm/Controller.php'; require_once 'HTML/QuickForm/Action/Next.php'; require_once 'HTML/QuickForm/Action/Back.php'; require_once 'HTML/QuickForm/Action/Jump.php'; require_once 'HTML/QuickForm/Action/Display.php'; // Start the session, form-page values will be kept there session_start(); define ('TEMPLATE_DIR', './template/'); define ('TEMPLATE_PAGE1', 't1.html'); class MyDisplay extends HTML_QuickForm_Action_Display { function _renderForm(&$page) { include_once 'HTML/QuickForm.php'; include_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; include_once 'Smarty.class.php'; # setup a template object $tpl =& new Smarty; $tpl->template_dir = TEMPLATE_DIR; $tpl->compile_dir = TEMPLATE_DIR; $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); $renderer->setRequiredTemplate( '{if $error} <font color="red">{$label}</font> {else} {$label} {/if}' ); $renderer->setErrorTemplate(''); # assign array with form data $tpl->assign('form', $renderer->toArray()); # capture the array structure ob_start(); print_r($renderer->toArray()); $tpl->assign('static_array', ob_get_contents()); ob_end_clean(); // $tpl->setCallbackFunction('buttonName', array(&$page, 'getButtonName')); # Get content of the page $content = $tpl->get(); $tpl->display(TEMPLATE_DIR . TEMPLATE_PAGE1); $page->display(); } } Etc. ------------------------------------------------------------------------ ---------------------------------------------- Template: ------------------------------------------------------------------------ ---------------------------------------------- <form {$form.attributes}> <table width="700" height="20" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="580">{$form.requiredFields.label}</td> <td width="120" align="right">{$form.page.label}</td> </tr> <tr> <td colspan="2" align="right">&nbsp;</td> </tr> </table> <table width="700" border="0" cellpadding="4" cellspacing="0" class="surveytbl"> <tr> <td width="20" bgcolor="#B5C1D5"><span class="txt11Bold">{$form.comment1.label}</span></td> </tr> </table> <br> <table width="700" height="20" border="0" cellpadding="0" cellspacing="0"> <tr> <td>&nbsp;</td> </tr> <tr> <td align="center">{$form.submit.html}</td> </tr> </table> </form> ------------------------------------------------------------------------ --------------------------------------------------------

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