Horde_Form
in package
Horde_Form Master Class.
Tags
Table of Contents
- $_help : mixed
- $_sections : mixed
- $_autofilled : mixed
- $_currentSection : mixed
- $_enctype : mixed
- $_errors : mixed
- $_extra : mixed
- $_hiddenVariables : mixed
- $_name : mixed
- $_open_section : mixed
- $_reset : mixed
- $_submit : mixed
- $_submitted : mixed
- $_title : mixed
- $_useFormToken : mixed
- $_variables : mixed
- $_vars : mixed
- __construct() : mixed
- _getInfoFromVariables() : mixed
- Fetch the field values from a given array of variables.
- _preserveVarByPost() : mixed
- addHidden() : mixed
- TODO
- addVariable() : mixed
- TODO
- appendButtons() : mixed
- clearError() : mixed
- clearValidation() : mixed
- close() : mixed
- execute() : mixed
- getError() : mixed
- getErrors() : mixed
- getExtra() : mixed
- getInfo() : mixed
- Fetch the field values of the submitted form.
- getName() : mixed
- getOpenSection() : mixed
- getRenderer() : object
- Get the renderer for this form, either a custom renderer or the standard one.
- getSectionDesc() : mixed
- getSectionExpandedState() : mixed
- getSectionImage() : mixed
- getTitle() : mixed
- getType() : mixed
- Initialize a Horde_Form_Type object from a type id
- getVariables() : mixed
- getVars() : mixed
- hasHelp() : mixed
- insertVariableBefore() : mixed
- TODO
- isSubmitted() : bool
- Determines if this form has been submitted or not. If the class var _submitted is null then it will check for the presence of the formname in the form variables.
- isValid() : mixed
- onSubmit() : mixed
- Checks if there is anything to do on the submission of the form by looping through each variable's onSubmit() function.
- open() : mixed
- preserve() : mixed
- preserveVarByPost() : mixed
- removeVariable() : bool
- Removes a variable from the form.
- renderActive() : mixed
- Renders the form for editing.
- renderInactive() : mixed
- Renders the form for displaying.
- setButtons() : mixed
- setError() : mixed
- setExtra() : mixed
- setOpenSection() : mixed
- setSection() : mixed
- setSubmitted() : mixed
- Explicitly sets the state of the form submit.
- setTitle() : mixed
- setVars() : mixed
- singleton() : mixed
- unsetVars() : mixed
- useToken() : bool
- Sets or gets whether the form should be verified by tokens.
- validate() : bool
- Validates the form, checking if it really has been submitted by calling isSubmitted() and if true does any onSubmit() calls for variable types in the form. The _submitted variable is then rechecked.
Properties
$_help
public
mixed
$_help
= \false
$_sections
public
mixed
$_sections
= array()
$_autofilled
protected
mixed
$_autofilled
= \false
$_currentSection
protected
mixed
$_currentSection
= array()
$_enctype
protected
mixed
$_enctype
= \null
$_errors
protected
mixed
$_errors
= array()
$_extra
protected
mixed
$_extra
= ''
$_hiddenVariables
protected
mixed
$_hiddenVariables
= array()
$_name
protected
mixed
$_name
= ''
$_open_section
protected
mixed
$_open_section
= \null
$_reset
protected
mixed
$_reset
= \false
$_submit
protected
mixed
$_submit
= array()
$_submitted
protected
mixed
$_submitted
= \null
$_title
protected
mixed
$_title
= ''
$_useFormToken
protected
mixed
$_useFormToken
= \true
$_variables
protected
mixed
$_variables
= array()
$_vars
protected
mixed
$_vars
Methods
__construct()
public
__construct(mixed $vars[, mixed $title = '' ][, mixed $name = null ]) : mixed
Parameters
- $vars : mixed
- $title : mixed = ''
- $name : mixed = null
Return values
mixed —_getInfoFromVariables()
Fetch the field values from a given array of variables.
public
_getInfoFromVariables(array<string|int, mixed> $variables, object &$vars, array<string|int, mixed> &$info) : mixed
Parameters
- $variables : array<string|int, mixed>
-
An array of Horde_Form_Variable objects to fetch from.
- $vars : object
-
The Variables object.
- $info : array<string|int, mixed>
-
The array to be filled with the submitted field values.
Tags
Return values
mixed —_preserveVarByPost()
public
_preserveVarByPost(mixed $varname, mixed $value) : mixed
Parameters
- $varname : mixed
- $value : mixed
Tags
Return values
mixed —addHidden()
TODO
public
addHidden(mixed $humanName, mixed $varName, mixed $type, mixed $required[, mixed $readonly = false ][, mixed $description = null ][, mixed $params = array() ]) : mixed
Parameters
- $humanName : mixed
- $varName : mixed
- $type : mixed
- $required : mixed
- $readonly : mixed = false
- $description : mixed = null
- $params : mixed = array()
Tags
Return values
mixed —addVariable()
TODO
public
addVariable(mixed $humanName, mixed $varName, mixed $type, mixed $required[, mixed $readonly = false ][, mixed $description = null ][, mixed $params = array() ]) : mixed
Parameters
- $humanName : mixed
- $varName : mixed
- $type : mixed
- $required : mixed
- $readonly : mixed = false
- $description : mixed = null
- $params : mixed = array()
Return values
mixed —appendButtons()
public
appendButtons(mixed $submit) : mixed
Parameters
- $submit : mixed
Return values
mixed —clearError()
public
clearError(mixed $var) : mixed
Parameters
- $var : mixed
Return values
mixed —clearValidation()
public
clearValidation() : mixed
Return values
mixed —close()
public
close(mixed $renderer) : mixed
Parameters
- $renderer : mixed
Return values
mixed —execute()
public
execute() : mixed
Return values
mixed —getError()
public
getError(mixed $var) : mixed
Parameters
- $var : mixed
Return values
mixed —getErrors()
public
getErrors() : mixed
Return values
mixed —getExtra()
public
getExtra() : mixed
Return values
mixed —getInfo()
Fetch the field values of the submitted form.
public
getInfo(Variables $vars, array<string|int, mixed> &$info) : mixed
Parameters
- $vars : Variables
-
A Variables instance, optional since Horde 3.2.
- $info : array<string|int, mixed>
-
Array to be filled with the submitted field values.
Return values
mixed —getName()
public
getName() : mixed
Return values
mixed —getOpenSection()
public
getOpenSection() : mixed
Return values
mixed —getRenderer()
Get the renderer for this form, either a custom renderer or the standard one.
public
getRenderer([array<string|int, mixed> $params = array() ]) : object
To use a custom form renderer, your form class needs to
override this function:
function getRenderer()
{
return new CustomFormRenderer();
}
... where CustomFormRenderer is the classname of the custom renderer class, which should extend Horde_Form_Renderer.
Parameters
- $params : array<string|int, mixed> = array()
-
A hash of renderer-specific parameters.
Return values
object —Horde_Form_Renderer The form renderer.
getSectionDesc()
public
getSectionDesc(mixed $section) : mixed
Parameters
- $section : mixed
Return values
mixed —getSectionExpandedState()
public
getSectionExpandedState(mixed $section[, mixed $boolean = false ]) : mixed
Parameters
- $section : mixed
- $boolean : mixed = false
Return values
mixed —getSectionImage()
public
getSectionImage(mixed $section) : mixed
Parameters
- $section : mixed
Return values
mixed —getTitle()
public
getTitle() : mixed
Return values
mixed —getType()
Initialize a Horde_Form_Type object from a type id
public
getType(mixed $type[, mixed $params = array() ]) : mixed
Parameters
- $type : mixed
- $params : mixed = array()
Tags
Return values
mixed —getVariables()
public
getVariables([mixed $flat = true ][, mixed $withHidden = false ]) : mixed
Parameters
- $flat : mixed = true
- $withHidden : mixed = false
Return values
mixed —getVars()
public
getVars() : mixed
Return values
mixed —hasHelp()
public
hasHelp() : mixed
Return values
mixed —insertVariableBefore()
TODO
public
insertVariableBefore(mixed $before, mixed $humanName, mixed $varName, mixed $type, mixed $required[, mixed $readonly = false ][, mixed $description = null ][, mixed $params = array() ]) : mixed
Parameters
- $before : mixed
- $humanName : mixed
- $varName : mixed
- $type : mixed
- $required : mixed
- $readonly : mixed = false
- $description : mixed = null
- $params : mixed = array()
Return values
mixed —isSubmitted()
Determines if this form has been submitted or not. If the class var _submitted is null then it will check for the presence of the formname in the form variables.
public
isSubmitted() : bool
Other events can explicitly set the _submitted variable to false to indicate a form submit but not for actual posting of data (eg. onChange events to update the display of fields).
Return values
bool —True or false indicating if the form has been submitted.
isValid()
public
isValid() : mixed
Return values
mixed —onSubmit()
Checks if there is anything to do on the submission of the form by looping through each variable's onSubmit() function.
public
onSubmit(Horde_Variables &$vars) : mixed
Parameters
- $vars : Horde_Variables
Return values
mixed —open()
public
open(mixed &$renderer, mixed &$vars, mixed $action[, mixed $method = 'get' ][, mixed $enctype = null ]) : mixed
Parameters
- $renderer : mixed
- $vars : mixed
- $action : mixed
- $method : mixed = 'get'
- $enctype : mixed = null
Return values
mixed —preserve()
public
preserve(mixed $vars) : mixed
Parameters
- $vars : mixed
Return values
mixed —preserveVarByPost()
public
preserveVarByPost(mixed &$vars, mixed $varname[, mixed $alt_varname = '' ]) : mixed
Parameters
- $vars : mixed
- $varname : mixed
- $alt_varname : mixed = ''
Return values
mixed —removeVariable()
Removes a variable from the form.
public
removeVariable(Horde_Form_Variable|string &$var) : bool
As only variables can be passed by reference, you need to call this
method this way if want to pass a variable name:
$form->removeVariable($var = 'varname');
Parameters
- $var : Horde_Form_Variable|string
-
Either the variable's name or the variable to remove from the form.
Return values
bool —True if the variable was found (and deleted).
renderActive()
Renders the form for editing.
public
renderActive([Horde_Form_Renderer $renderer = null ][, Variables $vars = null ][, string $action = '' ][, string $method = 'get' ][, string $enctype = null ][, bool $focus = true ]) : mixed
Parameters
- $renderer : Horde_Form_Renderer = null
-
A renderer instance, optional since Horde 3.2.
- $vars : Variables = null
-
A Variables instance, optional since Horde 3.2.
- $action : string = ''
-
The form action (url).
- $method : string = 'get'
-
The form method, usually either 'get' or 'post'.
- $enctype : string = null
-
The form encoding type. Determined automatically if null.
- $focus : bool = true
-
Focus the first form field?
Return values
mixed —renderInactive()
Renders the form for displaying.
public
renderInactive([Horde_Form_Renderer $renderer = null ][, Variables $vars = null ]) : mixed
Parameters
- $renderer : Horde_Form_Renderer = null
-
A renderer instance, optional since Horde 3.2.
- $vars : Variables = null
-
A Variables instance, optional since Horde 3.2.
Return values
mixed —setButtons()
public
setButtons(mixed $submit[, mixed $reset = false ]) : mixed
Parameters
- $submit : mixed
- $reset : mixed = false
Return values
mixed —setError()
public
setError(mixed $var, mixed $message) : mixed
Parameters
- $var : mixed
- $message : mixed
Return values
mixed —setExtra()
public
setExtra(mixed $extra) : mixed
Parameters
- $extra : mixed
Return values
mixed —setOpenSection()
public
setOpenSection(mixed $section) : mixed
Parameters
- $section : mixed
Return values
mixed —setSection()
public
setSection([mixed $section = '' ][, mixed $desc = '' ][, mixed $image = '' ][, mixed $expanded = true ]) : mixed
Parameters
- $section : mixed = ''
- $desc : mixed = ''
- $image : mixed = ''
- $expanded : mixed = true
Return values
mixed —setSubmitted()
Explicitly sets the state of the form submit.
public
setSubmitted([bool $state = true ]) : mixed
An event can override the automatic determination of the submit state in the isSubmitted() function.
Parameters
- $state : bool = true
-
Whether to set the state of the form as being submitted.
Return values
mixed —setTitle()
public
setTitle(mixed $title) : mixed
Parameters
- $title : mixed
Return values
mixed —setVars()
public
setVars(mixed &$vars) : mixed
Parameters
- $vars : mixed
Return values
mixed —singleton()
public
singleton(mixed $form, mixed &$vars[, mixed $title = '' ][, mixed $name = null ]) : mixed
Parameters
- $form : mixed
- $vars : mixed
- $title : mixed = ''
- $name : mixed = null
Tags
Return values
mixed —unsetVars()
public
unsetVars(mixed &$vars) : mixed
Parameters
- $vars : mixed
Return values
mixed —useToken()
Sets or gets whether the form should be verified by tokens.
public
useToken([bool $token = null ]) : bool
Tokens are used to verify that a form is only submitted once.
Parameters
- $token : bool = null
-
If specified, sets whether to use form tokens.
Return values
bool —Whether form tokens are being used.
validate()
Validates the form, checking if it really has been submitted by calling isSubmitted() and if true does any onSubmit() calls for variable types in the form. The _submitted variable is then rechecked.
public
validate([Variables $vars = null ][, mixed $canAutoFill = false ]) : bool
Parameters
- $vars : Variables = null
-
A Variables instance, optional since Horde 3.2.
- $canAutoFill : mixed = false
Return values
bool —True if the form is valid.