Form.php
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.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Form
Package: Zend_FormZend_Form
- Implements
- Children
- \Zend_Dojo_Form
- \Zend_Form_SubForm
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Version
- $Id$
Constants


ENCTYPE_URLENCODED
= 'application/x-www-form-urlencoded'

ENCTYPE_MULTIPART
= 'multipart/form-data'Properties
Methods



__call(string $method, array $args) : stringOverloading: allow rendering specific decorators
Call renderDecoratorName() to render a specific decorator.
Parameters| Name | Type | Description |
|---|
| $method | string | |
|---|
| $args | array | |
|---|
ReturnsThrows


__get(string $name) : \Zend_Form_Element | \Zend_Form | nullOverloading: access to elements, form groups, and display groups
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


__isset(string $name) : booleanOverloading: access to elements, form groups, and display groups
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


__unset(string $name) : voidOverloading: access to elements, form groups, and display groups
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|



_array_replace_recursive(array $into) : voidThis is a helper function until php 5.3 is widespreaded
Parameters| Name | Type | Description |
|---|
| $into | array | |
|---|
Details- Access
- protected



_attachToArray(mixed $value, string $arrayPath) : arrayConverts given arrayPath to an array and attaches given value at the end of it.
Parameters| Name | Type | Description |
|---|
| $value | mixed | The value to attach |
|---|
| $arrayPath | string | Given array path to convert and attach to. |
|---|
Returns 


_dissolveArrayUnsetKey(array $array, string | null $arrayPath, string $key) : arrayGiven an array, an optional arrayPath and a key this method
dissolves the arrayPath and unsets the key within the array
if it exists.
Parameters| Name | Type | Description |
|---|
| $array | array | |
|---|
| $arrayPath | string | null | |
|---|
| $key | string | |
|---|
Returns 


_dissolveArrayValue(array $value, string $arrayPath) : stringExtract 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').
Parameters| Name | Type | Description |
|---|
| $value | array | Array to walk |
|---|
| $arrayPath | string | Array notation path of the part to extract |
|---|
Returns


_getArrayName(string $value) : stringDetermine array key name from given value
Given a value such as foo[bar][baz], returns the last element (in this case, 'baz').
Parameters| Name | Type | Description |
|---|
| $value | string | |
|---|
Returns


_getDecorator(string $name, null | array $options) : \Zend_Form_Decorator_InterfaceInstantiate a decorator based on class name or class name fragment
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
| $options | null | array | |
|---|
Returns 


_loadDecorator(array $decorator, mixed $name) : \Zend_Form_Decorator_InterfaceParameters| Name | Type | Description |
|---|
| $decorator | array | Decorator type and options |
|---|
| $name | mixed | Decorator name or alias |
|---|
Returns 


_setElementsBelongTo(string $name = null) : voidSet array to which elements belong
Parameters| Name | Type | Description |
|---|
| $name | string | Element name |
|---|



addAttribs(array $attribs) : \Zend_FormAdd multiple form attributes at once
Parameters| Name | Type | Description |
|---|
| $attribs | array | |
|---|
Returns 


addDecorators(array $decorators) : \Zend_FormAdd many decorators at once
Parameters| Name | Type | Description |
|---|
| $decorators | array | |
|---|
Returns 


addDisplayGroupPrefixPath(string $prefix, string $path) : \Zend_FormAdd prefix path for all display groups
Parameters| Name | Type | Description |
|---|
| $prefix | string | |
|---|
| $path | string | |
|---|
Returns 


addDisplayGroupPrefixPaths(array $spec) : \Zend_FormAdd multiple display group prefix paths at once
Parameters| Name | Type | Description |
|---|
| $spec | array | |
|---|
Returns 


addDisplayGroups(array $groups) : \Zend_FormAdd multiple display groups at once
Parameters| Name | Type | Description |
|---|
| $groups | array | |
|---|
Returns 


addElementPrefixPath(string $prefix, string $path, string $type = null) : \Zend_FormAdd prefix path for all elements
Parameters| Name | Type | Description |
|---|
| $prefix | string | |
|---|
| $path | string | |
|---|
| $type | string | |
|---|
Returns 


addElementPrefixPaths(array $spec) : \Zend_FormAdd prefix paths for all elements
Parameters| Name | Type | Description |
|---|
| $spec | array | |
|---|
Returns 


addElements(array $elements) : \Zend_FormAdd multiple elements at once
Parameters| Name | Type | Description |
|---|
| $elements | array | |
|---|
Returns 


addError(string $message) : \Zend_FormAdd an error message and mark element as failed validation
Parameters| Name | Type | Description |
|---|
| $message | string | |
|---|
Returns 


addErrorMessage(string $message) : \Zend_FormAdd a custom error message to return in the event of failed validation
Parameters| Name | Type | Description |
|---|
| $message | string | |
|---|
Returns 


addErrorMessages(array $messages) : \Zend_FormAdd multiple custom error messages to return in the event of failed validation
Parameters| Name | Type | Description |
|---|
| $messages | array | |
|---|
Returns 


addErrors(array $messages) : \Zend_FormAdd multiple error messages and flag element as failed validation
Parameters| Name | Type | Description |
|---|
| $messages | array | |
|---|
Returns 


addPrefixPath(string $prefix, string $path, string $type = null) : \Zend_FormAdd 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/'
Parameters| Name | Type | Description |
|---|
| $prefix | string | |
|---|
| $path | string | |
|---|
| $type | string | |
|---|
ReturnsThrows


addPrefixPaths(array $spec) : \Zend_FormAdd many prefix paths at once
Parameters| Name | Type | Description |
|---|
| $spec | array | |
|---|
Returns 


addSubForms(array $subForms) : \Zend_FormAdd multiple form subForms/subforms at once
Parameters| Name | Type | Description |
|---|
| $subForms | array | |
|---|
Returns 


filterName(string $value, bool $allowBrackets = false) : stringFilter a name to only allow valid variable characters
Parameters| Name | Type | Description |
|---|
| $value | string | |
|---|
| $allowBrackets | bool | |
|---|
Returns 


getAttrib(string $key) : mixedRetrieve a single form attribute
Parameters| Name | Type | Description |
|---|
| $key | string | |
|---|
Returns 


getElement(string $name) : \Zend_Form_Element | nullRetrieve a single element
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


getElementsAndSubFormsOrdered() : arrayReturns 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.
ReturnsDetails- Access
- protected



getElementsBelongTo() : string | nullGet name of array elements belong to
Returns| Type | Description |
|---|
| string | null | |



getErrors(string $name = null, $suppressArrayNotation = false) : arrayGet error codes for all elements failing validation
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
| $suppressArrayNotation | | |
|---|
Returns 


getMessages(string $name = null, bool $suppressArrayNotation = false) : arrayRetrieve error messages from elements failing validations
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
| $suppressArrayNotation | bool | |
|---|
Returns 


getPluginLoader(string $type = null) : \Zend_Loader_PluginLoader_InterfaceRetrieve 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.
Parameters| Name | Type | Description |
|---|
| $type | string | |
|---|
Returns


getSubForm(string $name) : \Zend_Form | nullRetrieve a form subForm/subform
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


getUnfilteredValue(string $name) : mixedGet unfiltered element value
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


getValidValues(array $data, bool $suppressArrayNotation = false) : arrayReturns 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.
Parameters| Name | Type | Description |
|---|
| $data | array | |
|---|
| $suppressArrayNotation | bool | |
|---|
Returns


getValue(string $name) : mixedRetrieve value for single element
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


getValues(bool $suppressArrayNotation = false) : arrayRetrieve all form element values
Parameters| Name | Type | Description |
|---|
| $suppressArrayNotation | bool | |
|---|
Returns 


isErrors() : boolAre there errors in the form?
ReturnsDetails- Deprecated
- since 1.11.1 - use hasErrors() instead



processAjax(array $data) : stringProcess 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()}).
Parameters| Name | Type | Description |
|---|
| $data | array | |
|---|
Returns| Type | Description |
|---|
| string | JSON-encoded boolean true or error messages |



removeDecorator(string $name) : boolRemove a single decorator
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


removeDisplayGroup(string $name) : booleanRemove a display group by name
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


removeFromIteration(string $name) : voidRemove an element from iteration
Parameters| Name | Type | Description |
|---|
| $name | string | Element/group/form name |
|---|



removeSubForm(string $name) : booleanRemove form subForm/subform
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
Returns 


setAttribs(array $attribs) : \Zend_FormSet multiple form attributes at once
Overwrites any previously set attributes.
Parameters| Name | Type | Description |
|---|
| $attribs | array | |
|---|
Returns


setDefault(string $name, mixed $value) : \Zend_FormSet default value for an element
Parameters| Name | Type | Description |
|---|
| $name | string | |
|---|
| $value | mixed | |
|---|
Returns 


setDefaultDisplayGroupClass(string $class) : \Zend_FormSet default display group class
Parameters| Name | Type | Description |
|---|
| $class | string | |
|---|
Returns 


setDefaults(array $defaults) : \Zend_FormSet default values for elements
Sets values for all elements specified in the array of $defaults.
Parameters| Name | Type | Description |
|---|
| $defaults | array | |
|---|
Returns


setDisableLoadDefaultDecorators(bool $flag) : \Zend_FormSet flag to disable loading default decorators
Parameters| Name | Type | Description |
|---|
| $flag | bool | |
|---|
Returns 


setDisableTranslator(bool $flag) : \Zend_FormIndicate whether or not translation should be disabled
Parameters| Name | Type | Description |
|---|
| $flag | bool | |
|---|
Returns 


setDisplayGroupDecorators(array $decorators) : \Zend_FormSet all display group decorators as specified
Parameters| Name | Type | Description |
|---|
| $decorators | array | |
|---|
Returns 


setDisplayGroups(array $groups) : \Zend_FormAdd multiple display groups (overwrites)
Parameters| Name | Type | Description |
|---|
| $groups | array | |
|---|
Returns 


setElementDecorators(array $decorators, array | null $elements = null, bool $include = true) : \Zend_FormSet all element decorators as specified
Parameters| Name | Type | Description |
|---|
| $decorators | array | |
|---|
| $elements | array | null | Specific elements to decorate or exclude from decoration |
|---|
| $include | bool | Whether $elements is an inclusion or exclusion list |
|---|
Returns 


setElementFilters(array $filters) : \Zend_FormSet all elements' filters
Parameters| Name | Type | Description |
|---|
| $filters | array | |
|---|
Returns 


setElements(array $elements) : \Zend_FormSet form elements (overwrites existing elements)
Parameters| Name | Type | Description |
|---|
| $elements | array | |
|---|
Returns 


setElementsBelongTo(string $array) : \Zend_FormSet name of array elements belong to
Parameters| Name | Type | Description |
|---|
| $array | string | |
|---|
Returns 


setErrorMessages(array $messages) : \Zend_FormSame as addErrorMessages(), but clears custom error message stack first
Parameters| Name | Type | Description |
|---|
| $messages | array | |
|---|
Returns 


setErrors(array $messages) : \Zend_FormOverwrite any previously set error messages and flag as failed validation
Parameters| Name | Type | Description |
|---|
| $messages | array | |
|---|
Returns 


setIsArray(bool $flag) : \Zend_FormSet flag indicating elements belong to array
Parameters| Name | Type | Description |
|---|
| $flag | bool | Value of flag |
|---|
Returns 


setOptions(array $options) : \Zend_FormSet form state from options array
Parameters| Name | Type | Description |
|---|
| $options | array | |
|---|
Returns 


setSubFormDecorators(array $decorators) : \Zend_FormSet all subform decorators as specified
Parameters| Name | Type | Description |
|---|
| $decorators | array | |
|---|
Returns 


setSubForms(array $subForms) : \Zend_FormSet multiple form subForms/subforms (overwrites)
Parameters| Name | Type | Description |
|---|
| $subForms | array | |
|---|
Returns