return html from run-method HTML_QuickForm_Controller

From: Date: Fri, 23 Jul 2004 21:46:18 +0000
Subject: return html from run-method HTML_QuickForm_Controller
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13837@lists.php.net to get a copy of this message
Hello dear developers, I followed the examples of QFC and found it to be a perfect wizard-creator, but I have an annoying problem: Is it possible to return the html-code from a single page? I played around for quite some time to retrieve the html for a single page but I did not find a way of doing so I already searched the list archives, but it did not deliver any satisfying result. All I need is a way of getting the output from one class via some $obj->toHtml() method-like thing from each class, so I can insert this html I retrieved into a collecting buffer, which contents itself will later be inserted into another template. is there a possibility? the code (simplified): <?php /** * Wizardpage to add new user-entry * * $Id: creatorwiz01.temp.inc.php,v 0.1 2004/07/23 23:09:08 phwen Exp $ */ require_once 'HTML/QuickForm/Controller.php'; // Load some default action handlers require_once 'HTML/QuickForm/Action/Submit.php'; require_once 'HTML/QuickForm/Action/Display.php'; session_start(); class ChooseGroupPage extends HTML_QuickForm_Page {
    function buildForm()
    {
        $this->_formBuilt = true;
        $sql='
            SELECT
                name,
                salon_id
            FROM
                salons
            ORDER BY
                salons.name ASC
        ';
        $salonbox =&
HTML_QuickForm::createElement('select','_v2',htmlentities('Bitte wählen Sie einen Salon aus'));
        $PEAR_DSN='mysql://YYYY:XXXX@mysqlsrv.tr.biz/bigpointdax';
        $salonbox->loadQuery($PEAR_DSN,$sql);
        $this->addElement($salonbox);
        // Bind the button to the 'submit' action
        $this->addElement('submit',     $this->getButtonName('next'), 'Next');
        $this->setDefaultAction('next');
    }
} class TestingPage2 extends HTML_QuickForm_Page {
    function buildForm()
    {
        $this->_formBuilt = true;
        $this->addElement('text','somestuff',"somestuff1");
        // Bind the button to the 'submit' action
        $this->addElement('submit',     $this->getButtonName('submit'), 'submit');
        $this->setDefaultAction('submit');
    }
} class ActionDisplay extends HTML_QuickForm_Action_Display {
    function _renderForm(&$page)
    {
        $renderer =& $page->defaultRenderer();
        $renderer->setFormTemplate('<table width="450" border="0" cellpadding="3" cellspacing="2" bgcolor="#CCCC99"><form{attributes}>{content}</form></table>');
        $renderer->setHeaderTemplate('<tr><td style="white-space:nowrap;background:#996;color:#ffc;" align="left" colspan="2"><b>{header}</b></td></tr>');
        $renderer->setGroupTemplate('<table><tr>{content}</tr></table>', 'name');
        $renderer->setGroupElementTemplate('<td>{element}<br /><span style="font-size:10px;"><!-- BEGIN required --><span style="color: #f00">*</span><!-- END required --><span style="color:#996;">{label}</span></span></td>', 'name');
        $page->accept($renderer);
        echo $renderer->toHtml();
    }
} class ActionProcess extends HTML_QuickForm_Action {
    function perform(&$page, $actionName)
    {
        //here comes lots of other db- and system-stuff
        echo "Done..<br>\n<pre>\n";
        var_dump($page->controller->exportValues());
        echo "\n</pre>\n";
    }
} $wizard =& new HTML_QuickForm_Controller('UserCreateWizard', true); $wizard->addPage(new ChooseGroupPage('page1')); $wizard->addPage(new TestingPage2('page2')); $wizard->addAction('display', new ActionDisplay()); $wizard->addAction('process', new ActionProcess()); $wizard->run(); ?>

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