PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm_Controller » Manual

This is an add-on to HTML_QuickForm package that allows (among other things) to build multipage forms. Cool features: Includes several default Actions that allow easy building of multipage forms. Includes usage examples for common usage cases (single-page form, wizard, tabbed form).

Introduction

Introduction – What is this package useful for

Why "Controller"?

This package implements a PageController design pattern, which essentially means that there is a single page processing requests and actions this page performs depend on parameters passed in GET or POST data. The pattern is described in more detail on Martin Fowler's website and WACT project website.

What does this mean in application to QuickForm: we have a single script which shows and validates different forms depending on data in request. This allows to fairly easy build very complex forms consisting of several pages (think wizards and such).

The most basic implementation of the PageController pattern would look like

<?php
switch ($_REQUEST['action']) {
    case 'foo': 
        doFoo(); 
        break;
    case 'bar': 
        doBar(); 
        break;
    default:
        echo 'Hello, world!';
}
?>

HTML_QuickForm_Controller is a bit more complex. There are three base classes:

The action sent in request consists of a page name and an action name, it defines which Page will process the request (e.g. display or validate the form) and what exactly this Page should do.

Basic usage example

Session initialization

This simple example does not use sessions since there is no need to pass data between pages. You'll need to use sessions when dealing with a real multipage form, though. HTML_QuickForm_Controller does not start a session automatically, you should explicitly call session_start() before instantiating the controller class.

To ease understanding of this package's features, lets take an example form from HTML_QuickForm tutorial and redo it using HTML_QuickForm_Controller:

Basic Controller usage

<?php
// Load the controller
require_once 'HTML/QuickForm/Controller.php';
// Load the base Action class (we will subclass it later)
require_once 'HTML/QuickForm/Action.php';

// Class representing a form
class FirstPage extends HTML_QuickForm_Page
{
    function buildForm()
    {
        $this->_formBuilt = true;

        // Add some elements to the form
        $this->addElement('header', null, 'QuickForm tutorial example');
        $this->addElement('text', 'name', 'Enter your name:', array('size' => 50, 'maxlength' => 255));
        // Note how we set the name of the submit button
        $this->addElement('submit', $this->getButtonName('submit'), 'Send');

        // Define filters and validation rules
        $this->applyFilter('name', 'trim');
        $this->addRule('name', 'Please enter your name', 'required', null, 'client');

        $this->setDefaultAction('submit');
    }
}

// Action to process the form
class ActionProcess extends HTML_QuickForm_Action
{
    function perform(&$page, $actionName)
    {
        echo '<h1>Hello, ' . htmlspecialchars($page->exportValue('name')) . '!</h1>';
    }
}

$page =& new FirstPage('firstForm');

// We only add the 'process' handler, Controller will care for default ones
$page->addAction('process', new ActionProcess());

// Instantiate the Controller
$controller =& new HTML_QuickForm_Controller('tutorial');

// Set defaults for the form elements
$controller->setDefaults(array(
    'name' => 'Joe User'
));

// Add the page to Controller
$controller->addPage($page);

// Process the request
$controller->run();
?>

You may note that the code is more verbose than the original. That is true, but to make a three page wizard-type form you'll only need to create three subclasses of HTML_QuickForm_Page and 'process' event handler based on HTML_QuickForm_Action and add them to Controller, while without the Controller infrastructure it will require a non-trivial amount of programming.

Creating custom pages

You need to subclass HTML_QuickForm_Page and override its buildForm() method. Its contents are pretty self-explanatory (if you are familiar with QuickForm), except for a few things:

<?php
$this->_formBuilt = true;
?>

Form building is a "heavy" operation, thus we call buildForm() only when necessary. To prevent calling it twice (and getting two sets of elements instead of one) we set $_formBuilt property.

The second notable line is

<?php
$this->addElement('submit', $this->getButtonName('submit'), 'Send');
?>

We use getButtonName() method to set the submit button's name and thus to trigger a 'submit' action when the button is clicked.

The third thing is

<?php
$this->setDefaultAction('submit');
?>

The user can submit the form by pressing Enter button, not by clicking on any of the form buttons. Most browsers will not consider any submit button as clicked in this case and will not send its name. setDefaultAction() sets the action (by adding a special hidden element to the form) that will be called in this case.

Creating custom actions

You'll usually need to create handlers for two actions: 'process' and 'display'. While it is difficult to say anything about the former, as only you know how to process your form, for the latter you'll need to subclass HTML_QuickForm_Action_Display and override its _renderForm() method to call the appropriate Renderer and do form output customization.

Tying this all together

Next we instantiate the page class defined above

<?php
$page =& new FirstPage('firstForm');
?>

and add our custom action handler to it

<?php
$page->addAction('process', new ActionProcess());
?>

the 'process' action will be called by the default 'submit' action handler if the form is valid.

Then we instantiate the controller

<?php
$controller =& new HTML_QuickForm_Controller('tutorial');
?>

Note that the name is a required parameter, and if you will have several Controllers in your application they should have different names, as the names are used to store values in sessions.

Then we set the defaults for the form and add the page to it

<?php
$controller->setDefaults(array(
    'name' => 'Joe User'
));
$controller->addPage($page);
?>

It is perfectly legal to do call Page's setDefaults() from within buildForm(), but the former approach allows to set the defaults for the form as a whole, while the latter only for the page in question.

Finally we call the Controller's run() method

<?php
$controller->run();
?>

which will take care of finding the name of the current action and calling the necessary handler. That's all.

Advanced usage examples

...are available in the package archive. Along with the example similar to the provided above, there are two multipage forms:

FAQ

FAQ – Understanding package features

Description

This document is based on questions asked on PEAR general mailing list. You are encouraged to search the list archives to find more verbose answers and examples.

How do I change the action attribute of the <form> tag?

The only reason constructor of HTML_QuickForm_Page does not provide a means to set the action attribute is to make it harder to shoot oneself in the foot. That being said, the attribute can still be changed by setAttribute() or updateAttributes() method of HTML_QuickForm_Page (these are inherited from HTML_Common, and you should really consider learning its API).

Meta-question: actions

To avoid confusion lets use the terms "action" for the string containing the name of the action and "action handler" for the subclass of HTML_QuickForm_Action.

Default actions and default action handlers

While you can invent your own action names and create custom handlers for them, you'll most certainly have to deal with the default actions and their handlers first.

'display'

This action has a default handler, HTML_QuickForm_Action_Display, which displays the form using the Default renderer. You should subclass this handler if you want to customize the form output. This action is called automatically when the page needs to be displayed and should not be bound to buttons via getButtonName().

'submit'

This action should be bound to a "global" submit button for a form. It can be the "submit" button of a single-page or tabbed multi-page form, "finish" button of a wizard. This action has a default handler, HTML_QuickForm_Action_Submit, which checks whether all the pages of the form are valid, then either calls the 'process' handler or displays the invalid page.

'next'

This action should be bound to the "Next" button of (usually) a modal multipage form (AKA wizard). This action has a default handler, HTML_QuickForm_Action_Next, which checks the validity of the current page and redirects to the next one if the current is valid (or if the form is not modal). On the last page of a modal multipage form this behaves like the default 'submit' handler.

'back'

This action should be bound to the "Back" button of (usually) a modal multipage form (AKA wizard). This action has a default handler, HTML_QuickForm_Action_Back, which redirects to the previous page if one exists. As of QFC 0.9.3, no form validation takes place on 'back' action.

'jump'

This action has a default handler, HTML_QuickForm_Action_Jump, which just makes HTTP redirect to the given page of the form. This action should not be bound to buttons via getButtonName().

'process'

This is the action called by default 'submit' and 'next' (on the last page of the wizard only) handlers after successful (i.e. without validation errors) form submit. This action doesn't have a default handler, you should define the custom one yourself and implement all the necessary logic to process the form's values in it.

There is also a default handler, HTML_QuickForm_Action_Direct, that does not have a default action name. It is used to go to the specific page of the form and should be explicitly added via Page::addAction() or Controller::addAction() with the name of the target page as $actionName and bound to buttons via getButtonName() using the same name.

How to call an action handler?

You should use Page's handle() method:

<?php
$page->handle('action');
?>

Controller's handle() method will be called automatically if needed.

How to make a custom action?

Create a subclass of HTML_QuickForm_Action, add the necessary logic to its perform() method. Add it to the Page or to the Controller via addAction() with the appropriate name.

If you intend to bind this action to some button via getButtonName(), you should care about storing values in the container():

  1. Build the form.
  2. Get a reference to container.
  3. Fill the container's ['values'][$pageName] and ['valid'][$pageName] elements.

As usual, see the default action handlers' source for the examples.

Can actions be bound to something other than submit buttons?

Controller is able to properly handle actions bound to <input type="image" /> controls, too. You don't have to do anything special, just set the control's name via getButtonName().

If you want to bind an action to something like a hyperlink, you must consider the following: the form must be submitted to be able to get its values, thus you need to write some javascript that will submit the form and somehow pass the action name to the controller.

How do I reset the form?

Controller keeps the form data and validation status in session in so-called container, accessible via container() method. To reset the form you need to clear this container, which is achieved by passing TRUE to container().

How to pass additional data between pages of the form?

The answer is quite simple: you need to use the container() method of HTML_QuickForm_Controller, like this:

<?php
// Note the reference
$data =& $page->controller->container();
$data['_my_stuff'] = $stuff;
?>

On the target page you do

<?php
$data =& $page->controller->container();
$stuff = $data['_my_stuff'];
?>

Please use some prefix for your fields or start their names with underscore to prevent possible name conflicts with the future versions of QFC.

Please note that Controller knows nothing about your additional data, so do not expect it to return it via exportValues() method or the like. You'll have to use the container() method and extract the data yourself. However, your data will be deleted when the container is reset.

How to use template-based renderers?

First of all, please understand that HTML_QuickForm_Page is a subclass of HTML_QuickForm, thus everything that applies to the parent class will apply to the child. You are encouraged to read the section about renderers in HTML_QuickForm and the docs to the renderer you are trying to use. The usage examples are available in docs/renderers/ directory of QuickForm distribution.

As was already pointed out, you should subclass the HTML_QuickForm_Action_Display class if you want to customize the form output and add an instance of this subclass as a handler for Page's 'display' action. Its _renderForm() will contain all renderer-specific code.

The only new problem Controller introduces is the buttons bound to specific actions via getButtonName(). If you are using some kind of Dynamic renderer this will not be a problem, as you need not care about the elements names, but you need these names to output the form via Static renderer.

We'll assume using ITStatic renderer but the same can be applied to other Static renderers as well. You basically have 3 options:

  1. Manually add the buttons/placeholders with the names that should be autogenerated via getButtonName() to the form. This is not recommended, as the names should not be of interest to anyone except Controller itself and should not be used directly.
  2. Put the auto-named buttons into group. You can name the group any way you like, just be sure to set $appendName to false. When ITStatic sees {form_element_html} placeholder, it'll assign group's HTML to it.
  3. Call getButtonName() from within template. Add the following to the template
    <input type="submit" value="Bla-bla" name="func_buttonName('action')" ... /> and the following to the _renderForm() method of your custom HTML_QuickForm_Action_Display subclass
    <?php
    $tpl->setCallbackFunction('buttonName', array(&$page, 'getButtonName'));
    ?>
    This code will work with HTML_Template_Sigma, HTML_Template_ITX (note the X) will require some more tweaking.

How to create a wizard with optional pages?

Thanks to Donald Lobo for this contribution.

Lets assume we have a three-page wizard:

You need to create several action handlers based on QFC's default HTML_QuickForm_Action_Next and HTML_QuickForm_Action_Back. You can do this either at the Page level or at the Controller level. The Page level subclassing is simple, but if you have a complex StateMachine you will end up having multiple subclasses.

For the above example, the 'next' action on page 1 sends the 'user' to either page 2 or page 3 based on input. The handler also sets the 'valid' flag of the page that will not be visited.

The 'back' action on pages 2A and 2B sends the user back to page 1, while the 'next' action sends him to page 3.

Finally, the 'back' action handler on page 3 should examine the input on page 1 and send the user to either 2A or 2B.

The working example is available in statemachine.php file.

I use client-side validation. How do I switch it off for 'Back' button?

Client-side validation is called by form's onSubmit handler, if you remove the handler, the validation will not run. Therefore you need to remove it if user clicks on 'Back' button. This can be achieved f.e. by adding the following as the button's onClick handler:

this.form.onsubmit = null; return true;

Class Summary HTML_QuickForm_Controller

Class Summary HTML_QuickForm_Controller – The class implementing a PageController pattern.

Description

This class keeps track of pages and (default) action handlers for the form, it manages keeping the form values in session, setting defaults and constants for the form as a whole and getting its submit values.

Generally you don't need to subclass this.

Class Trees for HTML_QuickForm_Controller

constructor HTML_QuickForm_Controller()

constructor HTML_QuickForm_Controller() – Class constructor.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void constructor HTML_QuickForm_Controller::HTML_QuickForm_Controller ( string $name , bool $modal = true )

Description

Sets the form name and modal/non-modal behaviour. Different multipage forms should have different names, as they are used to store form values in session. Modal forms allow passing to the next page only when all of the previous pages are valid.

Parameter

string $name

form name

boolean $modal

whether the form is modal

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::addAction()

Controller::addAction() – Registers a handler for a specific action.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::addAction ( string $actionName , object HTML_QuickForm_Action &$action )

Description

This handler will be used if the Page that has to handle some action does not have a handler itself.

Parameter

string $actionName

name of the action

object HTML_QuickForm_Action &$action

the handler for the action

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::addPage()

Controller::addPage() – Adds a new page to the form

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::addPage ( object HTML_QuickForm_Page &$page )

Description

This package is not documented yet.

Parameter

object HTML_QuickForm_Page &$page

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::applyDefaults()

Controller::applyDefaults() – Sets the default values for the given page

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::applyDefaults ( string $pageName )

Description

This is used to load Page's default and constant values from the container.

Parameter

string $pageName

Name of a page

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::container()

Controller::container() – Returns a reference to the form's values container.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

array &HTML_QuickForm_Controller::container ( bool $reset = false )

Description

Session initialization

The package does store the data in session, but it does not start the session automatically. You must call session_start() function yourself before instantiating HTML_QuickForm_Controller.

Returns a reference to a session variable containing the form-page values and pages' validation status. This is a "low-level" method, use exportValues() if you want just to get the form's values.

The structure of the container is the following


array (
    'defaults'  => array(... default form values ...),
    'constants' => array(... constant form values ...),
    'values'    => array(
        'page1' => array(... submitted values for this page ...),
        ...
        'pageN' => array(... submitted values for this page ...)
    ),
    'valid'     => array(
        'page1' => null if the page was never validated, true if valid, false otherwise
        ...
        'pageN' => null if the page was never validated, true if valid, false otherwise
    )
)

Parameter

boolean $reset

If true, then reset the container: clear all default, constant and submitted values

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::exportValue()

Controller::exportValue() – Returns the element's value

Synopsis

require_once 'HTML/QuickForm/Controller.php';

mixed HTML_QuickForm_Controller::exportValue ( string $pageName , string $elementName )

Description

This package is not documented yet.

Parameter

string $pageName

name of the page

string $elementName

name of the element in the page

Return value

returns value for the element

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::exportValues()

Controller::exportValues() – Returns the form's values

Synopsis

require_once 'HTML/QuickForm/Controller.php';

array HTML_QuickForm_Controller::exportValues ( string $pageName = null )

Description

This package is not documented yet.

Parameter

string $pageName

name of the page, if not set then returns values for all pages

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::findInvalid()

Controller::findInvalid() – Finds the (first) invalid page

Synopsis

require_once 'HTML/QuickForm/Controller.php';

string HTML_QuickForm_Controller::findInvalid ( )

Description

This package is not documented yet.

Return value

returns Name of an invalid page

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::getActionName()

Controller::getActionName() – Finds the names of the current page and the current action.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

array HTML_QuickForm_Controller::getActionName ( )

Description

This method searches the $_REQUEST array for an element with a special name and splits the name into page name and action. If such an element is not found, the first page will be default and 'display' the default action.

Return value

returns first element is page name, second is action name

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::getNextName()

Controller::getNextName() – Returns the name of the page after the given.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

string HTML_QuickForm_Controller::getNextName ( string $pageName )

Description

This package is not documented yet.

Parameter

string $pageName

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::getPage()

Controller::getPage() – Returns a page

Synopsis

require_once 'HTML/QuickForm/Controller.php';

object HTML_QuickForm_Page &HTML_QuickForm_Controller::getPage ( string $pageName )

Description

This package is not documented yet.

Parameter

string $pageName

Name of a page

Return value

returns A reference to the page

Throws

throws PEAR_Error

Note

This function can not be called statically.

Controller::getPrevName()

Controller::getPrevName() – Returns the name of the page before the given.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

string HTML_QuickForm_Controller::getPrevName ( string $pageName )

Description

This package is not documented yet.

Parameter

string $pageName

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::handle()

Controller::handle() – Handles an action.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::handle ( object HTML_QuickForm_Page &$page , string $actionName )

Description

This will be called if the page itself does not have a handler to a specific action. The method also loads and uses default handlers for common actions, if specific ones were not added.

Parameter

object HTML_QuickForm_Page &$page

The page that failed to handle the action

string $actionName

Name of the action

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::isModal()

Controller::isModal() – Checks whether the form is modal.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

bool HTML_QuickForm_Controller::isModal ( )

Description

This package is not documented yet.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::isValid()

Controller::isValid() – Checks whether the pages of the controller are valid

Synopsis

require_once 'HTML/QuickForm/Controller.php';

bool HTML_QuickForm_Controller::isValid ( string $pageName = null )

Description

This package is not documented yet.

Parameter

string $pageName

If set, check only the pages before (not including) that page

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::run()

Controller::run() – Processes the request.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::run ( )

Description

This finds the current page, the current action and passes the action to the page's handle() method.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::setConstants()

Controller::setConstants() – Initializes constant form values.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::setConstants ( array $constantValues = null )

Description

These values won't get overridden by POST or GET vars

Parameter

array $constantValues

constant values

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Controller::setDefaults()

Controller::setDefaults() – Initializes default form values.

Synopsis

require_once 'HTML/QuickForm/Controller.php';

void HTML_QuickForm_Controller::setDefaults ( array $defaultValues = null )

Description

This package is not documented yet.

Parameter

array $defaultValues

default values

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Class Summary HTML_QuickForm_Page

Class Summary HTML_QuickForm_Page – The class represents a page of a multipage form.

Description

Generally you'll need to subclass this and define your buildForm() method that will build the form. While it is also possible to instantiate this class and build the form manually, this is not the recommended way.

Class Trees for HTML_QuickForm_Page

constructor HTML_QuickForm_Page()

constructor HTML_QuickForm_Page() – Class constructor

Synopsis

require_once 'HTML/QuickForm/Page.php';

void constructor HTML_QuickForm_Page::HTML_QuickForm_Page ( string $formName , string $method = 'post' , string $target = '_self' , mixed $attributes = null )

Description

Note that unlike constructor of HTML_QuickForm there is no $action, as the form is always submitted to the current page. Note also that $formName is not optional.

Parameter

string $formName

Form's name

string $method

Form's method

string $target

Form's target

mixed $attributes

Extra attributes for <form> tag

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::addAction()

Page::addAction() – Registers a handler for a specific action.

Synopsis

require_once 'HTML/QuickForm/Page.php';

void HTML_QuickForm_Page::addAction ( string $actionName , object HTML_QuickForm_Action &$action )

Description

This package is not documented yet.

Parameter

string $actionName

name of the action

object HTML_QuickForm_Action &$action

the handler for the action

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::buildForm()

Page::buildForm() – Builds a form.

Synopsis

require_once 'HTML/QuickForm/Page.php';

void HTML_QuickForm_Page::buildForm ( )

Description

Builds a form. You should override this method when you subclass HTML_QuickForm_Page, it should contain all the necessary addElement(), applyFilter(), addRule() and possibly setDefaults() and setConstants() calls. The method will be called on demand, so please be sure to set $_formBuilt property to TRUE to assure that the method works only once.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::getButtonName()

Page::getButtonName() – Returns a name for a submit button that will invoke a specific action.

Synopsis

require_once 'HTML/QuickForm/Page.php';

string HTML_QuickForm_Page::getButtonName ( string $actionName )

Description

Returns a name for a submit button (or an <input type="image"> control) that will invoke a specific action. This means the following: if you do

<?php
$this->addElement('submit', $this->getButtonName('foo'), 'Foo');
?>

inside the buildForm() method and the user later uses this button to submit the form, then the 'foo' handler (added via addAction() will be called.

Parameter

string $actionName

Name of the action

Return value

returns "name" attribute for a submit button

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::handle()

Page::handle() – Handles an action.

Synopsis

require_once 'HTML/QuickForm/Page.php';

void HTML_QuickForm_Page::handle ( string $actionName )

Description

This method simply calls the perform() method of an Action object registered for this action name. If an Action object for it was not registered here, controller's handle() method will be called.

Parameter

string $actionName

Name of the action

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::isFormBuilt()

Page::isFormBuilt() – Checks whether the form was already built.

Synopsis

require_once 'HTML/QuickForm/Page.php';

bool HTML_QuickForm_Page::isFormBuilt ( )

Description

This is used to check whether it is necessary to call buildForm() or not.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::loadValues()

Page::loadValues() – Loads the submit values from the array.

Synopsis

require_once 'HTML/QuickForm/Page.php';

void HTML_QuickForm_Page::loadValues ( array $values )

Description

The method is NOT intended for general usage. It should be used to assign form values from the container instead of from actual request data.

Parameter

array $values

'submit' values

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Page::setDefaultAction()

Page::setDefaultAction() – Sets the default action invoked on page-form submit.

Synopsis

require_once 'HTML/QuickForm/Page.php';

void HTML_QuickForm_Page::setDefaultAction ( string $actionName )

Description

This is necessary as the user may just press Enter instead of clicking one of the named submit buttons and then no action name will be passed to the script.

This method adds a special hidden element to the form the contents of which will be used by Controller if no action name is found in the submitted values.

Parameter

string $actionName

default action name

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Class Summary HTML_QuickForm_Action

Class Summary HTML_QuickForm_Action – Class representing an action to perform on HTTP request.

Description

The Controller will select the appropriate Action to call on the request and call its perform() method. The subclasses of this class should implement all the necessary business logic.

The default action handlers are described in the FAQ section.

Class Trees for HTML_QuickForm_Action

Classes that extend HTML_QuickForm_Action
Class Summary
HTML_QuickForm_Action_Back The action for a 'back' button of wizard-type multipage form.
HTML_QuickForm_Action_Direct This action allows to go to a specific page of a multipage form.
HTML_QuickForm_Action_Display This action handles the output of the form.
HTML_QuickForm_Action_Jump The action handles the HTTP redirect to a specific page.
HTML_QuickForm_Action_Next The action for a 'next' button of wizard-type multipage form.
HTML_QuickForm_Action_Submit The action for a 'submit' button.

Action::perform()

Action::perform() – Processes the request.

Synopsis

require_once 'HTML/QuickForm/Action.php';

void HTML_QuickForm_Action::perform ( object HTML_QuickForm_Page &$page , string $actionName )

Description

This method should be overriden by child classes to provide the necessary logic.

Parameter

object HTML_QuickForm_Page &$page

the current form-page

string $actionName

Current action name, as one Action object can serve multiple actions

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Class Summary HTML_QuickForm_Action_Back

Class Summary HTML_QuickForm_Action_Back – The action for a 'back' button of wizard-type multipage form.

Description

This package is not documented yet.

Class Trees for HTML_QuickForm_Action_Back

Class Summary HTML_QuickForm_Action_Direct

Class Summary HTML_QuickForm_Action_Direct – This action allows to go to a specific page of a multipage form.

Description

Please note that the name for this action in addAction() should NOT be 'direct', but the name of the page you wish to go to.

Class Trees for HTML_QuickForm_Action_Direct

Class Summary HTML_QuickForm_Action_Display

Class Summary HTML_QuickForm_Action_Display – This action handles the output of the form.

Description

If you want to customize the form display, subclass this class and override the _renderForm() method, you don't need to change the perform() method itself.

Class Trees for HTML_QuickForm_Action_Display

Class Summary HTML_QuickForm_Action_Jump

Class Summary HTML_QuickForm_Action_Jump – The action handles the HTTP redirect to a specific page.

Description

This package is not documented yet.

Class Trees for HTML_QuickForm_Action_Jump

Class Summary HTML_QuickForm_Action_Next

Class Summary HTML_QuickForm_Action_Next – The action for a 'next' button of wizard-type multipage form.

Description

This package is not documented yet.

Class Trees for HTML_QuickForm_Action_Next

Class Summary HTML_QuickForm_Action_Submit

Class Summary HTML_QuickForm_Action_Submit – The action for a 'submit' button.

Description

This package is not documented yet.

Class Trees for HTML_QuickForm_Action_Submit