Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Zend_Form
DECORATOR = 'DECORATOR'
ELEMENT = 'ELEMENT'
METHOD_DELETE = 'delete'
METHOD_GET = 'get'
METHOD_POST = 'post'
METHOD_PUT = 'put'
ENCTYPE_URLENCODED = 'application/x-www-form-urlencoded'
ENCTYPE_MULTIPART = 'multipart/form-data'
array $_attribs = 'array'
Form metadata and attributes
array $_decorators = 'array'
Decorators for rendering
string $_defaultDisplayGroupClass = 'Zend_Form_DisplayGroup'
Default display group class
string $_description = ''
Form description
bool $_disableLoadDefaultDecorators = 'false'
Should we disable loading the default decorators?
array $_displayGroupPrefixPaths = 'array'
Display group prefix paths
array $_displayGroups = 'array'
Groups of elements grouped for display purposes
null|array $_elementDecorators = ''
Global decorators to apply to all elements
array $_elementPrefixPaths = 'array'
Prefix paths to use when creating elements
array $_elements = 'array'
Form elements
string $_elementsBelongTo = ''
Array to which elements belong (if any)
array $_errorMessages = 'array'
Custom form-level error messages
bool $_errorsExist = 'false'
Are there errors in the form?
bool $_errorsForced = 'false'
Has the form been manually flagged as an error?
int|null $_formOrder = ''
Form order
bool $_isArray = 'false'
Whether or not form elements are members of an array
bool $_isRendered = 'false'
string $_legend = ''
Form legend
array $_loaders = 'array'
Plugin loaders
array $_methods = 'array'
Allowed form methods
array $_order = 'array'
Order in which to display and iterate elements
bool $_orderUpdated = 'false'
Whether internal order has been updated or not
array $_subFormPrefixPaths = 'array'
Sub form prefix paths
array $_subForms = 'array'
Sub forms
Zend_Translate $_translator = ''
Zend_Translate $_translatorDefault = ''
Global default translation adapter
bool $_translatorDisabled = 'false'
is the translator disabled?
Zend_View_Interface $_view = ''
__call(
string $method, array $args
)
:
string
Overloading: allow rendering specific decorators
Call renderDecoratorName() to render a specific decorator.
__clone(
)
:
void
Clone form object and all children
__construct(
mixed $options
=
null
)
:
void
Constructor
Registers form view helper as decorator
__get(
string $name
)
:
Zend_Form_Element|Zend_Form|null
Overloading: access to elements, form groups, and display groups
__isset(
string $name
)
:
boolean
Overloading: access to elements, form groups, and display groups
__set(
string $name, Zend_Form_Element|Zend_Form $value
)
:
void
Overloading: access to elements, form groups, and display groups
__toString(
)
:
string
Serialize as string
Proxies to {@link render()}.
__unset(
string $name
)
:
void
Overloading: access to elements, form groups, and display groups
_addDisplayGroupObject(
Zend_Form_DisplayGroup $group, string|null $name
=
null
)
:
Zend_Form
Add a display group object (used with cloning)
_array_replace_recursive(
array $into
)
:
void
This is a helper function until php 5.3 is widespreaded
_attachToArray(
mixed $value, string $arrayPath
)
:
array
Converts given arrayPath to an array and attaches given value at the end of it.
_dissolveArrayUnsetKey(
array $array, string|null $arrayPath, string $key
)
:
array
Given an array, an optional arrayPath and a key this method dissolves the arrayPath and unsets the key within the array if it exists.
_dissolveArrayValue(
array $value, string $arrayPath
)
:
string
Extract the value by walking the array using given array path.
Given an array path such as foo[bar][baz], returns the value of the last element (in this case, 'baz').
_getArrayName(
string $value
)
:
string
Determine array key name from given value
Given a value such as foo[bar][baz], returns the last element (in this case, 'baz').
_getDecorator(
string $name, null|array $options
)
:
Zend_Form_Decorator_Interface
Instantiate a decorator based on class name or class name fragment
_getErrorMessages(
)
:
array
Retrieve optionally translated custom error messages
_getIsRendered(
)
:
Get the value of $_isRendered member
_loadDecorator(
array $decorator, mixed $name
)
:
Zend_Form_Decorator_Interface
Lazy-load a decorator
_setElementsBelongTo(
string $name
=
null
)
:
void
Set array to which elements belong
_setIsRendered(
)
:
When calling renderFormElements or render this method is used to set $_isRendered member to prevent repeatedly merging belongsTo setting
_sort(
)
:
void
Sort items according to their order
addAttribs(
array $attribs
)
:
Zend_Form
Add multiple form attributes at once
addDecorator(
string|Zend_Form_Decorator_Interface $decorator, array|Zend_Config $options
=
null
)
:
Zend_Form
Add a decorator for rendering the element
addDecorators(
array $decorators
)
:
Zend_Form
Add many decorators at once
addDisplayGroup(
array $elements, string $name, array|Zend_Config $options
=
null
)
:
Zend_Form
Add a display group
Groups named elements for display purposes.
If a referenced element does not yet exist in the form, it is omitted.
addDisplayGroupPrefixPath(
string $prefix, string $path
)
:
Zend_Form
Add prefix path for all display groups
addDisplayGroupPrefixPaths(
array $spec
)
:
Zend_Form
Add multiple display group prefix paths at once
addDisplayGroups(
array $groups
)
:
Zend_Form
Add multiple display groups at once
addElement(
string|Zend_Form_Element $element, string $name
=
null, array|Zend_Config $options
=
null
)
:
Zend_Form
Add a new element
$element may be either a string element type, or an object of type Zend_Form_Element. If a string element type is provided, $name must be provided, and $options may be optionally provided for configuring the element.
If a Zend_Form_Element is provided, $name may be optionally provided, and any provided $options will be ignored.
addElementPrefixPath(
string $prefix, string $path, string $type
=
null
)
:
Zend_Form
Add prefix path for all elements
addElementPrefixPaths(
array $spec
)
:
Zend_Form
Add prefix paths for all elements
addElements(
array $elements
)
:
Zend_Form
Add multiple elements at once
addError(
string $message
)
:
Zend_Form
Add an error message and mark element as failed validation
addErrorMessage(
string $message
)
:
Zend_Form
Add a custom error message to return in the event of failed validation
addErrorMessages(
array $messages
)
:
Zend_Form
Add multiple custom error messages to return in the event of failed validation
addErrors(
array $messages
)
:
Zend_Form
Add multiple error messages and flag element as failed validation
addPrefixPath(
string $prefix, string $path, string $type
=
null
)
:
Zend_Form
Add prefix path for plugin loader
If no $type specified, assumes it is a base path for both filters and validators, and sets each according to the following rules: - decorators: $prefix = $prefix . '_Decorator' - elements: $prefix = $prefix . '_Element'
Otherwise, the path prefix is set on the appropriate plugin loader.
If $type is 'decorator', sets the path in the decorator plugin loader for all elements. Additionally, if no $type is provided, the prefix and path is added to both decorator and element plugin loader with following settings: $prefix . '_Decorator', $path . '/Decorator/' $prefix . '_Element', $path . '/Element/'
addPrefixPaths(
array $spec
)
:
Zend_Form
Add many prefix paths at once
addSubForm(
Zend_Form $form, string $name, int $order
=
null
)
:
Zend_Form
Add a form group/subform
addSubForms(
array $subForms
)
:
Zend_Form
Add multiple form subForms/subforms at once
clearAttribs(
)
:
Zend_Form
Clear all form attributes
clearDecorators(
)
:
Zend_Form
Clear all decorators
clearDisplayGroups(
)
:
Zend_Form
Remove all display groups
clearElements(
)
:
Zend_Form
Remove all form elements
clearErrorMessages(
)
:
Zend_Form
Clear custom error messages stack
clearSubForms(
)
:
Zend_Form
Remove all form subForms/subforms
count(
)
:
int
Count of elements/subforms that are iterable
createElement(
string $type, string $name, array|Zend_Config $options
=
null
)
:
Zend_Form_Element
Create an element
Acts as a factory for creating elements. Elements created with this method will not be attached to the form, but will contain element settings as specified in the form object (including plugin loader prefix paths, default decorators, etc.).
current(
)
:
Zend_Form_Element|Zend_Form_DisplayGroup|Zend_Form
Current element/subform/display group
filterName(
string $value, bool $allowBrackets
=
false
)
:
string
Filter a name to only allow valid variable characters
getAction(
)
:
string
Get form action
Sets default to '' if not set.
getAttrib(
string $key
)
:
mixed
Retrieve a single form attribute
getAttribs(
)
:
array
Retrieve all form attributes/metadata
getCustomMessages(
)
:
array
Retrieve translated custom error messages Proxies to {@link _getErrorMessages()}.
getDecorator(
string $name
)
:
false|Zend_Form_Decorator_Abstract
Retrieve a registered decorator
getDecorators(
)
:
array
Retrieve all decorators
getDefaultDisplayGroupClass(
)
:
string
Retrieve default display group class
getDefaultTranslator(
)
:
null|Zend_Translate
Get global default translator object
getDescription(
)
:
string
Retrieve form description
getDisplayGroup(
string $name
)
:
Zend_Form_DisplayGroup|null
Return a display group
getDisplayGroups(
)
:
array
Return all display groups
getElement(
string $name
)
:
Zend_Form_Element|null
Retrieve a single element
getElements(
)
:
array
Retrieve all elements
getElementsAndSubFormsOrdered(
)
:
array
Returns a one dimensional numerical indexed array with the Elements, SubForms and Elements from DisplayGroups as Values.
Subitems are inserted based on their order Setting if set, otherwise they are appended, the resulting numerical index may differ from the order value.
getElementsBelongTo(
)
:
string|null
Get name of array elements belong to
getEnctype(
)
:
string
Get encoding type
getErrorMessages(
)
:
array
Retrieve custom error messages
getErrors(
string $name
=
null, $suppressArrayNotation
=
false
)
:
array
Get error codes for all elements failing validation
getFullyQualifiedName(
)
:
string
Get fully qualified name
Places name as subitem of array and/or appends brackets.
getId(
)
:
string
Get element id
getLegend(
)
:
string
Get form legend
getMessages(
string $name
=
null, bool $suppressArrayNotation
=
false
)
:
array
Retrieve error messages from elements failing validations
getMethod(
)
:
string
Retrieve form method
getName(
)
:
null|string
Get name attribute
getOrder(
)
:
int|null
Get form order
getPluginLoader(
string $type
=
null
)
:
Zend_Loader_PluginLoader_Interface
Retrieve plugin loader for given type
$type may be one of: - decorator - element
If a plugin loader does not exist for the given type, defaults are created.
getSubForm(
string $name
)
:
Zend_Form|null
Retrieve a form subForm/subform
getSubForms(
)
:
array
Retrieve all form subForms/subforms
getTranslator(
)
:
Zend_Translate|null
Retrieve translator object
getUnfilteredValue(
string $name
)
:
mixed
Get unfiltered element value
getUnfilteredValues(
)
:
array
Retrieve all unfiltered element values
getValidValues(
array $data, bool $suppressArrayNotation
=
false
)
:
array
Returns only the valid values from the given form input.
For models that can be saved in a partially valid state, for example when following the builder, prototype or state patterns it is particularly interessting to retrieve all the current valid values to persist them.
getValue(
string $name
)
:
mixed
Retrieve value for single element
getValues(
bool $suppressArrayNotation
=
false
)
:
array
Retrieve all form element values
getView(
)
:
Zend_View_Interface|null
Retrieve view object
If none registered, attempts to pull from ViewRenderer.
hasDefaultTranslator(
)
:
boolean
Is there a default translation object set?
hasTranslator(
)
:
bool
Does this form have its own specific translator?
init(
)
:
void
Initialize form (used by extending classes)
isArray(
)
:
bool
Get flag indicating if elements belong to an array
isErrors(
)
:
bool
Are there errors in the form?
isValid(
array $data
)
:
boolean
Validate the form
isValidPartial(
array $data
)
:
boolean
Validate a partial form
Does not check for required flags.
key(
)
:
string
Current element/subform/display group name
loadDefaultDecorators(
)
:
void
Load the default decorators
loadDefaultDecoratorsIsDisabled(
)
:
bool
Should we load the default decorators?
markAsError(
)
:
Zend_Form
Mark the element as being in a failed validation state
next(
)
:
void
Move pointer to next element/subform/display group
persistData(
)
:
populate(
array $values
)
:
Zend_Form
Populate form
Proxies to {@link setDefaults()}
processAjax(
array $data
)
:
string
Process submitted AJAX data
Checks if provided $data is valid, via {@link isValidPartial()}. If so, it returns JSON-encoded boolean true. If not, it returns JSON-encoded error messages (as returned by {@link getMessages()}).
removeAttrib(
string $key
)
:
bool
Remove attribute
removeDecorator(
string $name
)
:
bool
Remove a single decorator
removeDisplayGroup(
string $name
)
:
boolean
Remove a display group by name
removeElement(
string $name
)
:
boolean
Remove element
removeSubForm(
string $name
)
:
boolean
Remove form subForm/subform
render(
Zend_View_Interface $view
=
null
)
:
string
Render form
rewind(
)
:
void
Move pointer to beginning of element/subform/display group loop
setAction(
string $action
)
:
Zend_Form
Set form action
setAttrib(
string $key, mixed $value
)
:
Zend_Form
Set form attribute
setAttribs(
array $attribs
)
:
Zend_Form
Set multiple form attributes at once
Overwrites any previously set attributes.
setConfig(
Zend_Config $config
)
:
Zend_Form
Set form state from config object
setDecorators(
array $decorators
)
:
Zend_Form
Overwrite all decorators
setDefault(
string $name, mixed $value
)
:
Zend_Form
Set default value for an element
setDefaultDisplayGroupClass(
string $class
)
:
Zend_Form
Set default display group class
setDefaultTranslator(
Zend_Translate|Zend_Translate_Adapter|null $translator
=
null
)
:
void
Set global default translator object
setDefaults(
array $defaults
)
:
Zend_Form
Set default values for elements
Sets values for all elements specified in the array of $defaults.
setDescription(
string $value
)
:
Zend_Form
Set form description
setDisableLoadDefaultDecorators(
bool $flag
)
:
Zend_Form
Set flag to disable loading default decorators
setDisableTranslator(
bool $flag
)
:
Zend_Form
Indicate whether or not translation should be disabled
setDisplayGroupDecorators(
array $decorators
)
:
Zend_Form
Set all display group decorators as specified
setDisplayGroups(
array $groups
)
:
Zend_Form
Add multiple display groups (overwrites)
setElementDecorators(
array $decorators, array|null $elements
=
null, bool $include
=
true
)
:
Zend_Form
Set all element decorators as specified
setElementFilters(
array $filters
)
:
Zend_Form
Set all elements' filters
setElements(
array $elements
)
:
Zend_Form
Set form elements (overwrites existing elements)
setElementsBelongTo(
string $array
)
:
Zend_Form
Set name of array elements belong to
setEnctype(
string $value
)
:
Zend_Form
Set encoding type
setErrorMessages(
array $messages
)
:
Zend_Form
Same as addErrorMessages(), but clears custom error message stack first
setErrors(
array $messages
)
:
Zend_Form
Overwrite any previously set error messages and flag as failed validation
setIsArray(
bool $flag
)
:
Zend_Form
Set flag indicating elements belong to array
setLegend(
string $value
)
:
Zend_Form
Set form legend
setMethod(
string $method
)
:
Zend_Form
Set form method
Only values in {@link $_methods()} allowed
setName(
string $name
)
:
Zend_Form
Set form name
setOptions(
array $options
)
:
Zend_Form
Set form state from options array
setOrder(
int $index
)
:
Zend_Form
Set form order
setPluginLoader(
Zend_Loader_PluginLoader_Interface $loader, string $type
=
null
)
:
Zend_Form
Set plugin loaders for use with decorators and elements
setSubFormDecorators(
array $decorators
)
:
Zend_Form
Set all subform decorators as specified
setSubForms(
array $subForms
)
:
Zend_Form
Set multiple form subForms/subforms (overwrites)
setTranslator(
Zend_Translate|Zend_Translate_Adapter|null $translator
=
null
)
:
Zend_Form
Set translator object
setView(
Zend_View_Interface $view
=
null
)
:
Zend_Form
Set view object
translatorIsDisabled(
)
:
bool
Is translation disabled?
valid(
)
:
bool
Determine if current element/subform/display group is valid