SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class MultiStepFormController

Supports multistep forms

Variables

NameVisibilityDescription
$action_log
Should this controller log add/edit/delete actions?
$complete_function
Appendage to route, where user is redirected after save on final step
$page_title
Page title to be displayed on form steps
$route
Route to form, relative to site root
$session_key
Key for partitioning session data associated with this form, i.e. $_SESSION[$this->session_key]
$steps
Steps and functions/views used to implement them
Keys are step numbers, values are function (and matching view) names
e.g. [1 => 'intro', 2 => 'personal_details']
$table
Table into which data will be saved at the final step
$view_dir
Directory in which views are stored, without trailing slash

Functions

NameVisibilityDescription
__callpublicHandles methods that do not exist.
__constructpublic 
_runpublicThe router/kohana will invoke this method to invoke an action.
autoSetEmptyParamprotectedAuto-set the "empty" param for fields with foreign keys to be NULL
buildUrlprotectedBuilds a URL to the form at a particular step
checkStepprotectedCheck the user has access to a step
completepublicDisplay the thanks message after the process has been completed
deleteRecordprotectedDeletes a record, and logs the deletion
firstStepprotectedGets the number (should be 0 or 1) of first step of the process
formprotectedThe method used to drive the forms at each step
generateFormViewprotectedGenerates a form view from a JSON config file
getCssClassNamepublicReturn the class name for this controller, expressed in CSS style, i.e. with dashes
getModulePathpublicGets the relative path to the module the controller lives in, or sprout itself
getSessionprotectedInstantiate the session and make sure the session key is useable
jsonExtraValidateprotectedDo any additional validation prior to saving the record
loadEditJsonprotectedLoads a JSON config file for an automated edit-type form for this controller
loadFormJsonprotectedLoads a config file for a JsonForm associated with this controller
loadRecordprotectedFetches the pre-update record from the database.
logActionprotectedStores a history item in the database, recording an add (i.e. insert), edit, or delete.
logAddprotectedLogs an add action. This is a wrapper for Controller::logAction
logAddCategoryprotectedLogs the adding of a record to a category. This is a wrapper for Controller::logAction
logDeleteprotectedLogs a delete action. This is a wrapper for Controller::logAction
logDeleteCategoryprotectedLogs the removal of a record from a category. This is a wrapper for Controller::logAction
logEditprotectedLogs an edit action. This is a wrapper for Controller::logAction
replaceSetprotectedInserts records which are in $new_records, but are not in the specified table
saveprotectedDo any final preparation / data massaging; then call saveData and finally redirect.
saveDataprotectedSave the data, e.g. into a database, after successful validation at the
saveJsonDataprotectedAutomatically saves the data associated with a submission on a JSON-generated form
submitprotectedThe method used to drive the form submissions at each step
validateprotected 

public __call (from BaseController)

void $BaseController->__call ( string $method , array $args );

Handles methods that do not exist.

public __construct (from BaseController)

void $BaseController->__construct ( );

This function does not have a description

public _run (from BaseController)

void $BaseController->_run ( mixed $method , mixed $args );

The router/kohana will invoke this method to invoke an action.

If you please, you may wrap this method to create before/after hooks.

protected autoSetEmptyParam (from Controller)

null $Controller->autoSetEmptyParam ( array &$conf );

Auto-set the "empty" param for fields with foreign keys to be NULL

This greatly reduces the number of foreign-key constraints hit in day-to-day use,
especially with file fields.

protected buildUrl

string $MultiStepFormController->buildUrl ( int $step [, bool $include_first ] );

Builds a URL to the form at a particular step

protected checkStep

void $MultiStepFormController->checkStep ( mixed $session , mixed $step );

Check the user has access to a step

public complete

void $MultiStepFormController->complete ( );

Display the thanks message after the process has been completed

protected deleteRecord (from Controller)

int $Controller->deleteRecord ( string $table , int $record_id [, int $parent_log_id ] );

Deletes a record, and logs the deletion
This should be used by all _deleteSave methods
Starts a transaction and commits it if not already in a transaction when called

protected firstStep

int $MultiStepFormController->firstStep ( );

Gets the number (should be 0 or 1) of first step of the process

protected form

View $MultiStepFormController->form ( [ int $step ] );

The method used to drive the forms at each step
This should be called by the entry function of the subclass controller

protected generateFormView (from Controller)

array $Controller->generateFormView ( mixed $file_name );

Generates a form view from a JSON config file

public getCssClassName (from BaseController)

string $BaseController->getCssClassName ( );

Return the class name for this controller, expressed in CSS style, i.e. with dashes

Example: When called from BlogPostController --> 'blog-post-controller'

public getModulePath (from BaseController)

string $BaseController->getModulePath ( );

Gets the relative path to the module the controller lives in, or sprout itself

protected getSession

array $MultiStepFormController->getSession ( );

Instantiate the session and make sure the session key is useable

protected jsonExtraValidate (from Controller)

void $Controller->jsonExtraValidate ( int $id , Validator $validator );

Do any additional validation prior to saving the record

protected loadEditJson (from Controller)

array $Controller->loadEditJson ( );

Loads a JSON config file for an automated edit-type form for this controller

protected loadFormJson (from Controller)

array $Controller->loadFormJson ( string $file_name );

Loads a config file for a JsonForm associated with this controller

protected loadRecord (from Controller)

bool|array $Controller->loadRecord ( string $table , int $record_id );

Fetches the pre-update record from the database.
Used by the action log system, and disabled if the action log system has been turned off

protected logAction (from Controller)

int $Controller->logAction ( string $table , int $record_id , int $type , array $data [, int $parent_log_id ] );

Stores a history item in the database, recording an add (i.e. insert), edit, or delete.
Should be called AFTER the action has been made.
N.B. This is a low-level method; the friendlier wrapper methods are preferred;
e.g. Controller::logAdd, Controller::logEdit

protected logAdd (from Controller)

int $Controller->logAdd ( string $table , int $record_id );

Logs an add action. This is a wrapper for Controller::logAction

protected logAddCategory (from Controller)

int $Controller->logAddCategory ( string $table , int $record_id , int $cat_id );

Logs the adding of a record to a category. This is a wrapper for Controller::logAction

protected logDelete (from Controller)

int $Controller->logDelete ( string $table , int $record_id , array $data [, int $parent_log_id ] );

Logs a delete action. This is a wrapper for Controller::logAction

protected logDeleteCategory (from Controller)

int $Controller->logDeleteCategory ( string $table , int $record_id , int $cat_id );

Logs the removal of a record from a category. This is a wrapper for Controller::logAction

protected logEdit (from Controller)

int $Controller->logEdit ( string $table , int $record_id , array $data );

Logs an edit action. This is a wrapper for Controller::logAction

protected replaceSet (from Controller)

void $Controller->replaceSet ( string $table , array $new_records , array $conditions );

Inserts records which are in $new_records, but are not in the specified table
Deletes records which are in the specified table, but not in $new_records
Updates records which are in both

Matching is done on the 'id' field, as a result the $new_records arrays MUST contain an id field.

protected save

void $MultiStepFormController->save ( );

Do any final preparation / data massaging; then call saveData and finally redirect.
This should generally be overridden.

protected saveData

null|int $MultiStepFormController->saveData ( string $table , array $sub_tables , array $extra_fields );

Save the data, e.g. into a database, after successful validation at the
final step

protected saveJsonData (from Controller)

bool $Controller->saveJsonData ( array $conf , int &$item_id [, string $mode ] );

Automatically saves the data associated with a submission on a JSON-generated form

protected submit

void $MultiStepFormController->submit ( int $step );

The method used to drive the form submissions at each step
This should be called by the submit function of the subclass controller

protected validate

void $MultiStepFormController->validate ( int &$step , array $reqd , array $rules [, Validator $valid ] );

This function does not have a description