Source for file wizard.php
Documentation is available at wizard.php
* Usage example for HTML_QuickForm2_Controller: wizard
* @author Alexey Borzov <avb@php.net>
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Controller.php';
require_once 'HTML/QuickForm2/Renderer.php';
// Load some default action handlers
require_once 'HTML/QuickForm2/Controller/Action/Next.php';
require_once 'HTML/QuickForm2/Controller/Action/Back.php';
require_once 'HTML/QuickForm2/Controller/Action/Jump.php';
require_once 'HTML/QuickForm2/Controller/Action/Display.php';
// Start the session, form-page values will be kept there
$fs = $this->form->addElement ('fieldset')->setLabel ('Wizard page 1 of 3');
$radioGroup = $fs->addElement ('group')->setLabel ('Are you absolutely sure?');
$radioGroup->addElement ('radio', 'iradYesNo', array ('value' => 'Y'), array ('content' => 'Yes'));
$radioGroup->addElement ('radio', 'iradYesNo', array ('value' => 'N'), array ('content' => 'No'));
$fs->addElement ('submit', $this->getButtonName('next'), array ('value' => 'Next >>'));
$radioGroup->addRule ('required', 'Check Yes or No');
$fs = $this->form->addElement ('fieldset')->setLabel ('Wizard page 2 of 3');
$nameGroup = $fs->addElement ('group', 'name', array ('id' => 'nameGrp'))
->setSeparator ('<span class="separator">,</span>');
$nameGroup->addElement ('text', 'last', array ('size' => 20 ))
->addRule ('required', 'Last name is required');
$nameGroup->addElement ('text', 'first', array ('size' => 20 ))
$buttonGroup = $fs->addElement ('group');
$buttonGroup->addElement ('submit', $this->getButtonName('back'), array ('value' => '<< Back'));
$buttonGroup->addElement ('submit', $this->getButtonName('next'), array ('value' => 'Next >>'));
$fs = $this->form->addElement ('fieldset')->setLabel ('Wizard page 3 of 3');
$fs->addElement ('textarea', 'itxaTest', array ('rows' => 5 , 'cols' => 40 ))
->setLabel ('Parting words:')
->addRule ('required', 'Say something!');
$buttonGroup = $fs->addElement ('group');
$buttonGroup->addElement ('submit', $this->getButtonName('back'), array ('value' => '<< Back'));
$buttonGroup->addElement ('submit', $this->getButtonName('next'), array ('value' => 'Finish'));
protected function renderForm(HTML_QuickForm2 $form)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
/* Set up custom font and form width */
font-family: Arial,sans-serif;
/* Use default styles included with the package */
if ('@data_dir@' != '@' . 'data_dir@') {
$filename = '@data_dir@/HTML_QuickForm2/quickform.css';
<title>HTML_QuickForm2 basic elements example</title>
$renderer->setElementTemplateForGroupId (
'nameGrp', 'html_quickform2_element',
'<div class="element<qf:error> error</qf:error>"><qf:error><span class="error">{error}</span><br /></qf:error>{element}<br /><label for="{id}"><qf:required><span class="required">* </span></qf:required>{label}</label></div>'
$renderer->setTemplateForId (
'nameGrp', '<div class="row"><p class="label"><qf:required><span class="required">*</span></qf:required><qf:label><label>{label}</label></qf:label></p>{content}</div>'
echo $form->render ($renderer);
public function perform(HTML_QuickForm2_Controller_Page $page, $name)
echo "Submit successful!<br>\n<pre>\n";
var_dump($page->getController ()->getValue ());
// We actually add these handlers here for the sake of example
// They can be automatically loaded and added by the controller
// This is the action we should always define ourselves
// We redefine 'display' handler to use the proper stylesheets
Documentation generated on Wed, 10 Apr 2019 08:56:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|