Re: [Quickform controller] Override the display ??
| From: | Stefan Ohrmann | Date: | Thu, 09 Dec 2004 19:24:51 +0000 |
| Subject: | Re: [Quickform controller] Override the display ?? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16151@lists.php.net to get a copy of this message | ||
Hello,
Am 09.12.2004 15:26 schrieb Alexey Borzov:
>> /**
>> * The class extension for the displaying of the form
>> */
>> class displayForm extends HTML_QuickForm_Action_Display
>> {
>> function _renderForm()
>
> function _renderForm(&$page)
>
>> {
>> $tpl =& $GLOBALS['tpl'];
>> $formArray = array();
>> $formArray = $this->toArray();
>
> $formArray = $page->toArray();
>
>>
>> $templateFile = MF_TEMPLATE_ROOT .'/concertagenda/add_concert.tmpl';
>>
>> $tpl->assign('showtype','form');
>> $tpl->assign('formaction',$formArray['attributes']);
>> $tpl->assign('requirednote',$formArray['requirednote']);
>> $tpl->assign('elements',$formArray['elements']);
>>
>> return $tpl->fetch($templateFile);
>> }
>> }
The problem with this function is, that you never get the content out of
the controller, because the "perform" function of
"HTML_QuickForm_Action_Display" only calls the "_renderForm" function
without returning anything from it. This little change in the "perform"
function would make the controller more valuable to people using the
controller in a bigger picture. A quick fix could be:
class HTML_QuickForm_Action_Fetch extends HTML_QuickForm_Action_display
{
var $_output;
function perform(&$page, $actionName)
{
parent::perform($page, $actionName);
return $this->_output;
}
function _renderForm(&$page)
{
$this->_output = $page->toHtml(); //Or fill your template and
fetch the result to $this->_output
}
}
Then you could run the controller and get the output returned.
regards
Stefan