HTML_QuickForm_Controller + Smarty
| From: | Mark Steudel | Date: | Fri, 21 Oct 2005 16:41:58 +0000 |
| Subject: | HTML_QuickForm_Controller + Smarty | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-21582@lists.php.net to get a copy of this message | ||
I'm trying to adapt my QuickForm + Smarty functions to
HTML_QuickForm_Controller. I'm not that knowledable about classes, so this
is probably a base knowledge problem. I having problems assigning the HTML
printed out from the code and assigning it to the Smarty Variables.
TIA, Mark
Here's the code:
=========================
$tpl =& new Smarty;
$tpl->template_dir = '../../../smarty/templates';
$tpl->compile_dir = '../../../smarty/templates_c';
.
.
.
Create some forms here
.
.
.
class ActionDisplay extends HTML_QuickForm_Action_Display
{
function _displayForm( &$page, &$tpl )
{
$formData = $page->toArray( true); <-- This doesn't seem to
work
$tpl->assign('javascript', $formData[javascript]);
$tpl->assign('formattributes', $formData[attributes]);
$tpl->assign('hidden', $formData[hidden]);
// remove empty tags for xhtml compliance
$html = str_replace( '<b></b>', ' ', $form->toHtml()
);
// cut out any javasript that's generated
$html = preg_replace( '@<script[^>]*?>.*?</script>@si', '',
$html );
$html = preg_replace( '@<form[^>]*?>@si', '', $html );
$html = str_replace( '</form>', '', $html );
$html = preg_replace( '|<input.*?type="hidden".*?/>|','',
$html );
// display form
$tpl->assign('content', $html);
}
}
.
.
.
AddPages
AddActions
.
.
.
$tabbed->addAction('display', new ActionDisplay());
$tabbed->addAction('process', new ActionProcess());
$tabbed->run();
// compile and display page
$tpl->display('t_admin.tpl');