Source for file tabbed.php
Documentation is available at tabbed.php
* Example 3 for HTML_QuickForm_Controller: Tabbed form
* @version SVN: $Id: tabbed.php 289084 2009-10-02 06:53:09Z avb $
* @author Alexey Borzov <avb@php.net>
require_once 'HTML/QuickForm/Controller.php';
// Load some default action handlers
require_once 'HTML/QuickForm/Action/Submit.php';
require_once 'HTML/QuickForm/Action/Jump.php';
require_once 'HTML/QuickForm/Action/Display.php';
require_once 'HTML/QuickForm/Action/Direct.php';
$this->_formBuilt = true;
// Here we get all page names in the controller
$myName = $current = $this->getAttribute ('id');
while (null !== ($current = $this->controller->getPrevName ($current))) {
$pages[] = $current = $myName;
while (null !== ($current = $this->controller->getNextName ($current))) {
// Here we display buttons for all pages, the current one's is disabled
foreach ($pages as $pageName) {
$tabs[] = $this->createElement (
array ('class' => 'flat') + ($pageName == $myName? array ('disabled' => 'disabled'): array ())
$this->addGroup ($tabs, 'tabs', null , ' ', false );
$this->addElement ('submit', $this->getButtonName('submit'), 'Big Red Button', array ('class' => 'bigred'));
$this->addElement ('header', null , 'Foo page');
$radio[] = &$this->createElement ('radio', null , null , 'Yes', 'Y');
$radio[] = &$this->createElement ('radio', null , null , 'No', 'N');
$radio[] = &$this->createElement ('radio', null , null , 'Maybe', 'M');
$this->addGroup ($radio, 'iradYesNoMaybe', 'Do you want this feature?', '<br />');
$this->addElement ('text', 'tstText', 'Why do you want it?', array ('size'=>20 , 'maxlength'=>50 ));
$this->addRule ('iradYesNoMaybe', 'Check a radiobutton', 'required');
$this->addElement ('header', null , 'Bar page');
$this->addElement ('date', 'favDate', 'Favourite date:', array ('format' => 'd-M-Y', 'minYear' => 1950 , 'maxYear' => date('Y')));
$checkbox[] = &$this->createElement ('checkbox', 'A', null , 'A');
$checkbox[] = &$this->createElement ('checkbox', 'B', null , 'B');
$checkbox[] = &$this->createElement ('checkbox', 'C', null , 'C');
$checkbox[] = &$this->createElement ('checkbox', 'D', null , 'D');
$checkbox[] = &$this->createElement ('checkbox', 'X', null , 'X');
$checkbox[] = &$this->createElement ('checkbox', 'Y', null , 'Y');
$checkbox[] = &$this->createElement ('checkbox', 'Z', null , 'Z');
$this->addGroup ($checkbox, 'favLetter', 'Favourite letters:', array (' ', '<br />'));
$this->addElement ('header', null , 'Baz page');
$this->addElement ('textarea', 'textPoetry', 'Recite a poem:', array ('rows' => 5 , 'cols' => 40 ));
$this->addElement ('textarea', 'textOpinion', 'Did you like this demo?', array ('rows' => 5 , 'cols' => 40 ));
$this->addRule ('textPoetry', 'Pretty please!', 'required');
// We subclass the default 'display' handler to customize the output
function _renderForm (&$page)
$renderer = & $page->defaultRenderer ();
// Do some cheesy customizations
$renderer->setElementTemplate ("\n\t<tr>\n\t\t<td align=\"right\" valign=\"top\" colspan=\"2\">{element}</td>\n\t</tr>", 'tabs');
$renderer->setFormTemplate (<<<_HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Controller example 3: tabbed form</title>
input.bigred {font-weight: bold; background: #FF6666;}
input.flat {border-style: solid; border-width: 2px; border-color: #000000;}
function perform(&$page, $actionName)
echo "Submit successful!<br>\n<pre>\n";
var_dump($page->controller ->exportValues ());
$tabbed->addPage (new PageFoo('foo'));
$tabbed->addPage (new PageBar('bar'));
$tabbed->addPage (new PageBaz('baz'));
// These actions manage going directly to the pages with the same name
// We actually add these handlers here for the sake of example
// They can be automatically loaded and added by the controller
// The customized actions
$tabbed->setDefaults (array (
'favLetter' => array ('A' => true , 'Z' => true ),
'favDate' => array ('d' => 1 , 'M' => 1 , 'Y' => 2001 ),
'textOpinion' => 'Yes, it rocks!'
Documentation generated on Mon, 11 Mar 2019 15:34:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|