HTML_QuickForm2
[ class tree: HTML_QuickForm2 ] [ index: HTML_QuickForm2 ] [ all elements ]

Class: HTML_QuickForm2_Controller

Source Location: /HTML_QuickForm2-2.0.0/HTML/QuickForm2/Controller.php

Class Overview


Class implementing the Page Controller pattern for multipage forms


Author(s):

Version:

  • Release: 2.0.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 70]
Class implementing the Page Controller pattern for multipage forms

This class keeps track of pages and (default) action handlers for the form, it manages $_SESSION container for the form values, allows setting DataSources for the form as a whole and getting its value.



[ Top ]


Class Variables

$actionName =  null

[line 116]

The action extracted from HTTP request: array('page', 'action')
  • Access: protected

Type:   array


[ Top ]

$handlers = array()

[line 110]

Contains the mapping of action names to handlers (objects implementing HTML_QuickForm2_Controller_Action)
  • Access: protected

Type:   array


[ Top ]

$id =  null

[line 98]

Controller ID
  • Access: protected

Type:   string


[ Top ]

$pages = array()

[line 104]

Contains the pages (instances of HTML_QuickForm2_Controller_Page) of the multipage form
  • Access: protected

Type:   array


[ Top ]

$propagate =  true

[line 92]

Whether Controller ID should be sent in GET and POST parameters
  • Access: protected

Type:   boolean


[ Top ]

$sessionContainer =  null

[line 122]

A wrapper around session variable used to store form data
  • Access: protected



[ Top ]

$wizard =  true

[line 86]

Whether the form is a wizard
  • Access: protected

Type:   boolean


[ Top ]



Method Detail

__construct (Constructor)   [line 163]

HTML_QuickForm2_Controller __construct( [string $id = null], [boolean $wizard = true], [boolean $propagateId = false])

Class constructor

Sets the form ID, whether to send this ID in POST and GET parameters, wizard / non-wizard behaviour.

Different forms should be given different IDs, as they are used to store values in session. If $id is empty, the controller will try to find it in $_REQUEST, throwing the exception if this fails.

Wizard forms only allow going to the next page if all the previous ones are valid.

  • Throws: HTML_QuickForm2_NotFoundException if ID is not given and cannot be found in $_REQUEST, or session container is empty
  • Access: public

Parameters:

string   $id     Form ID
boolean   $wizard     Whether the form is a wizard
boolean   $propagateId     Whether form's ID should be sent with GET and POST parameters

[ Top ]

addDataSource   [line 453]

void addDataSource( HTML_QuickForm2_DataSource $datasource)

Adds a new data source to the Controller

Note that Controller data sources are stored in session, so your data source implementation should properly handle its (un)serialization.

  • Access: public

Parameters:

HTML_QuickForm2_DataSource   $datasource     Data source

[ Top ]

addHandler   [line 281]

void addHandler( string $actionName, HTML_QuickForm2_Controller_Action $action)

Adds a handler for a specific action
  • Access: public

Parameters:

string   $actionName     action name
HTML_QuickForm2_Controller_Action   $action     the handler for the action

[ Top ]

addPage   [line 322]

void addPage( HTML_QuickForm2_Controller_Page $page)

Adds a new page to the form
  • Access: public

Parameters:

HTML_QuickForm2_Controller_Page   $page     

[ Top ]

destroySessionContainer   [line 226]

void destroySessionContainer( )

Removes the session variable containing the controller data
  • Access: public

[ Top ]

findControllerID   [line 131]

string|null findControllerID( )

Finds a controller name in $_REQUEST
  • Return: Returns nulle if either a KEY_ID is not present in $_REQUEST or KEY_CONTAINER is not present in $_SESSION
  • Access: public

[ Top ]

getActionName   [line 237]

array getActionName( )

Extracts the name of the page and the action to perform with it from HTTP request data
  • Return: first element is page name, second is action name
  • Access: public

[ Top ]

getFirstInvalidPage   [line 435]

HTML_QuickForm2_Controller_Page|null getFirstInvalidPage( )

Returns the first page that failed validation
  • Access: public

[ Top ]

getId   [line 195]

string getId( )

Returns the form ID
  • Access: public

[ Top ]

getIterator   [line 483]

ArrayIterator getIterator( )

Returns an Iterator for the form's pages
  • Access: public

[ Top ]

getPage   [line 343]

HTML_QuickForm2_Controller_Page getPage( string $pageId)

Returns a page
  • Throws: HTML_QuickForm2_NotFoundException if there is no page with the given ID
  • Access: public

Parameters:

string   $pageId     Page ID

[ Top ]

getSessionContainer   [line 215]

HTML_QuickForm2_Controller_SessionContainer getSessionContainer( )

Returns the session container with the controller data
  • Access: public

[ Top ]

getValue   [line 467]

array getValue( )

Returns the form's values
  • Access: public

[ Top ]

handle   [line 299]

mixed handle( HTML_QuickForm2_Controller_Page $page, string $actionName)

Handles an action

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

  • Return: Return value of action handler
  • Throws: HTML_QuickForm2_NotFoundException if handler for an action is missing
  • Access: public

Parameters:

HTML_QuickForm2_Controller_Page   $page     form page
string   $actionName     action name

[ Top ]

isValid   [line 400]

bool isValid( [HTML_QuickForm2_Controller_Page $reference = null])

Checks whether the pages of the controller are valid
  • Access: public

Parameters:

HTML_QuickForm2_Controller_Page   $reference     If given, check only the pages before (not including) that page

[ Top ]

isWizard   [line 185]

boolean isWizard( )

Returns whether the form is a wizard
  • Access: public

[ Top ]

nextPage   [line 380]

HTML_QuickForm2_Controller_Page|null nextPage( HTML_QuickForm2_Controller_Page $reference)

Returns the page following the given one
  • Access: public

Parameters:

HTML_QuickForm2_Controller_Page   $reference     

[ Top ]

previousPage   [line 361]

HTML_QuickForm2_Controller_Page|null previousPage( HTML_QuickForm2_Controller_Page $reference)

Returns the page preceding the given one
  • Access: public

Parameters:

HTML_QuickForm2_Controller_Page   $reference     

[ Top ]

propagateId   [line 205]

boolean propagateId( )

Returns whether to send form id with GET and POST parameters
  • Access: public

[ Top ]

run   [line 269]

mixed run( )

Processes the request

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

  • Return: Return value of action handler
  • Throws: HTML_QuickForm2_Exception
  • Access: public

[ Top ]


Documentation generated on Tue, 26 Jun 2012 15:30:12 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.