Elgg  Version master
Public Member Functions | Protected Attributes | List of all members
Elgg\Forms\StickyForms Class Reference

Stick forms service. More...

Public Member Functions

 __construct (\ElggSession $session)
 Constructor. More...
 
 makeStickyForm (string $form_name, array $ignored_field_names=[])
 Save form submission data (all GET and POST vars) into a session cache. More...
 
 clearStickyForm (string $form_name)
 Remove form submission data from the session. More...
 
 isStickyForm (string $form_name)
 Does form submission data exist for this form? More...
 
 getStickyValue (string $form_name, string $variable= '', $default=null, bool $filter_result=true)
 Get a specific value from cached form submission data. More...
 
 getStickyValues (string $form_name, bool $filter_result=true)
 Get all submission data cached for a form. More...
 

Protected Attributes

 $session
 

Detailed Description

Stick forms service.

Since
1.10.0

Definition at line 11 of file StickyForms.php.

Constructor & Destructor Documentation

Elgg\Forms\StickyForms::__construct ( \ElggSession  $session)

Constructor.

Parameters
\ElggSession$sessionSession for storage

Definition at line 23 of file StickyForms.php.

Member Function Documentation

Elgg\Forms\StickyForms::clearStickyForm ( string  $form_name)

Remove form submission data from the session.

Call this if validation is successful in the action handler or when they sticky values have been used to repopulate the form after a validation error.

Parameters
string$form_nameForm namespace
Returns
void

Definition at line 71 of file StickyForms.php.

Elgg\Forms\StickyForms::getStickyValue ( string  $form_name,
string  $variable = '',
  $default = null,
bool  $filter_result = true 
)

Get a specific value from cached form submission data.

Parameters
string$form_nameThe name of the form
string$variableThe name of the variable
mixed$defaultDefault value if the variable does not exist in sticky cache
boolean$filter_resultFilter for bad input if true
Returns
mixed

Definition at line 100 of file StickyForms.php.

Elgg\Forms\StickyForms::getStickyValues ( string  $form_name,
bool  $filter_result = true 
)

Get all submission data cached for a form.

Parameters
string$form_nameThe name of the form
bool$filter_resultFilter for bad input if true
Returns
array

Definition at line 123 of file StickyForms.php.

Elgg\Forms\StickyForms::isStickyForm ( string  $form_name)

Does form submission data exist for this form?

Parameters
string$form_nameForm namespace
Returns
bool

Definition at line 85 of file StickyForms.php.

Elgg\Forms\StickyForms::makeStickyForm ( string  $form_name,
array  $ignored_field_names = [] 
)

Save form submission data (all GET and POST vars) into a session cache.

Call this from an action when you want all your submitted variables available if the submission fails validation and is sent back to the form

Parameters
string$form_nameName of the sticky form
string[]$ignored_field_names Field names which shouldn't be made sticky in this form
Returns
void

Definition at line 38 of file StickyForms.php.

Member Data Documentation

Elgg\Forms\StickyForms::$session
protected

Definition at line 16 of file StickyForms.php.


The documentation for this class was generated from the following file: