HTML_QuickForm_Controller ActionDisplay class with Smarty
| From: | Ed Greenberg | Date: | Wed, 26 Jan 2005 02:17:34 +0000 |
| Subject: | HTML_QuickForm_Controller ActionDisplay class with Smarty | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17160@lists.php.net to get a copy of this message | ||
So here I am in my ActionDisplay class in a wizard:
class ActionDisplay extends HTML_QuickForm_Action_Display
{
function _renderForm(&$page)
{
$t = Template::factory($app_root,$page->item_class);
// none of this is in scope... where is it?
$t->assign('category_id',$category_id);
$t->assign('language_id',$current_language);
$t->assign('category',$category_name);
$t->assign('region',$region_name);
$t->assign('language',$language_name);
$t->assign('item_class',$item_class);
$t->assign('breadcrumbs',$cat->get_breadcrumb_array());
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($t);
// build the HTML for the form
// NOTE: $form is not in scope. Where does it come from?
$form->accept($renderer);
// assign array with form data
$form_data=$renderer->toArray();
$form_data['txtSubject']['value'] = htmlentities($form_data['txtSubject']['value']);
$form_data['txtContent']['value'] = htmlentities($form_data['txtContent']['value']);
$t->assign('form_data', $form_data);
$t->display($template);
// parent::_renderForm(&$page);} } All of the $t->assigns that are "not in scope above" come from my main page that is setting up the wizard. I need to get it into scope in the class. Maybe I need a behavior (a la strategy pattern) to go out and get this stuff. Maybe I should go read about the Decoration Pattern :) The best idea I have so far is to stick all this decorative stuff in an array or a bean style object and store the bean inside the page object (present in $page) so I can stick things into the template. Unless I can make these things global variables (which feels bad) or reference them somehow. They aren't in the parent -- maybe the great grandparent? It also looks like $form is not in scope. Where do I get that. Is it an element of $page? _IS_ it $page? If anyone can help with these two issues, I'd much appreciate it. </edg>