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

Class: HTML_QuickForm2_Controller

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

Class Overview


Class implementing the Page Controller pattern for multipage forms


Author(s):

Version:

  • Release: 2.1.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 46]
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 92]

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

Type:   array


[ Top ]

$handlers = array()

[line 86]

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

Type:   array


[ Top ]

$id =  null

[line 74]

Controller ID
  • Access: protected

Type:   string


[ Top ]

$pages = array()

[line 80]

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

Type:   array


[ Top ]

$propagate =  true

[line 68]

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

Type:   boolean


[ Top ]

$sessionContainer =  null

[line 98]

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



[ Top ]

$wizard =  true

[line 62]

Whether the form is a wizard
  • Access: protected

Type:   boolean


[ Top ]



Method Detail

__construct (Constructor)   [line 139]

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 429]

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 257]

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 298]

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 202]

void destroySessionContainer( )

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

[ Top ]

findControllerID   [line 107]

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 213]

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 411]

HTML_QuickForm2_Controller_Page|null getFirstInvalidPage( )

Returns the first page that failed validation
  • Access: public

[ Top ]

getId   [line 171]

string getId( )

Returns the form ID
  • Access: public

[ Top ]

getIterator   [line 459]

ArrayIterator getIterator( )

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

[ Top ]

getPage   [line 319]

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 191]

HTML_QuickForm2_Controller_SessionContainer getSessionContainer( )

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

[ Top ]

getValue   [line 443]

array getValue( )

Returns the form's values
  • Access: public

[ Top ]

handle   [line 275]

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 376]

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 161]

boolean isWizard( )

Returns whether the form is a wizard
  • Access: public

[ Top ]

nextPage   [line 356]

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 337]

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 181]

boolean propagateId( )

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

[ Top ]

run   [line 245]

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 Wed, 10 Apr 2019 08:56:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.