Form.php

Show: PublicProtectedPrivateinherited
Table of Contents
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  

\Zend_Form

Package: Zend_Form
Zend_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

>VConstant  DECORATOR = 'DECORATOR'
>VConstant  ELEMENT = 'ELEMENT'
>VConstant  METHOD_DELETE = 'delete'
>VConstant  METHOD_GET = 'get'
>VConstant  METHOD_POST = 'post'
>VConstant  METHOD_PUT = 'put'
>VConstant  ENCTYPE_URLENCODED = 'application/x-www-form-urlencoded'
>VConstant  ENCTYPE_MULTIPART = 'multipart/form-data'

Properties

>VPropertyprotectedarray $_attribs = array()
Form metadata and attributes
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_decorators = array()
Decorators for rendering
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_defaultDisplayGroupClass = 'Zend_Form_DisplayGroup'
Default display group class
Default value'Zend_Form_DisplayGroup'Details
Type
string
>VPropertyprotectedstring $_description
Form description
Details
Type
string
>VPropertyprotectedbool $_disableLoadDefaultDecorators = false
Should we disable loading the default decorators?
Default valuefalseDetails
Type
bool
>VPropertyprotectedarray $_displayGroupPrefixPaths = array()
Display group prefix paths
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_displayGroups = array()
Groups of elements grouped for display purposes
Default valuearray()Details
Type
array
>VPropertyprotectednull|array $_elementDecorators
Global decorators to apply to all elements
Details
Type
null | array
>VPropertyprotectedarray $_elementPrefixPaths = array()
Prefix paths to use when creating elements
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_elements = array()
Form elements
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_elementsBelongTo
Array to which elements belong (if any)
Details
Type
string
>VPropertyprotectedarray $_errorMessages = array()
Custom form-level error messages
Default valuearray()Details
Type
array
>VPropertyprotectedbool $_errorsExist = false
Are there errors in the form?
Default valuefalseDetails
Type
bool
>VPropertyprotectedbool $_errorsForced = false
Has the form been manually flagged as an error?
Default valuefalseDetails
Type
bool
>VPropertyprotectedint|null $_formOrder
Form order
Details
Type
int | null
>VPropertyprotectedbool $_isArray = false
Whether or not form elements are members of an array
Default valuefalseDetails
Type
bool
>VPropertyprotectedbool $_isRendered = false
Default valuefalseDetails
Type
bool
>VPropertyprotectedstring $_legend
Form legend
Details
Type
string
>VPropertyprotectedarray $_loaders = array()
Plugin loaders
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_methods = array('delete', 'get', 'post', 'put')
Allowed form methods
Default valuearray('delete', 'get', 'post', 'put')Details
Type
array
>VPropertyprotectedarray $_order = array()
Order in which to display and iterate elements
Default valuearray()Details
Type
array
>VPropertyprotectedbool $_orderUpdated = false
Whether internal order has been updated or not
Default valuefalseDetails
Type
bool
>VPropertyprotectedarray $_subFormPrefixPaths = array()
Sub form prefix paths
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_subForms = array()
Sub forms
Default valuearray()Details
Type
array
>VPropertyprotected\Zend_Translate $_translator
Details
Type
\Zend_Translate
>VPropertyprotected\Zend_Translate $_translatorDefault
static
Global default translation adapter
Details
Type
\Zend_Translate
>VPropertyprotectedbool $_translatorDisabled = false
is the translator disabled?
Default valuefalseDetails
Type
bool
>VPropertyprotected\Zend_View_Interface $_view

Methods

methodpublic__call(string $method, array $args) : string

Overloading: allow rendering specific decorators

Call renderDecoratorName() to render a specific decorator.
Parameters
NameTypeDescription
$methodstring
$argsarray
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Form_Exceptionfor invalid decorator or invalid method call
methodpublic__clone() : void

Clone form object and all children

methodpublic__construct(mixed $options = null) : void

Constructor

Registers form view helper as decorator
Parameters
NameTypeDescription
$optionsmixed
methodpublic__get(string $name) : \Zend_Form_Element | \Zend_Form | null

Overloading: access to elements, form groups, and display groups

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form_Element | \Zend_Form | null
methodpublic__isset(string $name) : boolean

Overloading: access to elements, form groups, and display groups

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
boolean
methodpublic__set(string $name, \Zend_Form_Element | \Zend_Form $value) : void

Overloading: access to elements, form groups, and display groups

Parameters
NameTypeDescription
$namestring
$value\Zend_Form_Element | \Zend_Form
Throws
ExceptionDescription
\Zend_Form_Exceptionfor invalid $value
methodpublic__toString() : string

Serialize as string

Proxies to {@link render()}.
Returns
TypeDescription
string
methodpublic__unset(string $name) : void

Overloading: access to elements, form groups, and display groups

Parameters
NameTypeDescription
$namestring
methodprotected_addDisplayGroupObject(\Zend_Form_DisplayGroup $group, string | null $name = null) : \Zend_Form

Add a display group object (used with cloning)

Parameters
NameTypeDescription
$group\Zend_Form_DisplayGroup
$namestring | null
Returns
TypeDescription
\Zend_Form
methodprotected_array_replace_recursive(array $into) : void

This is a helper function until php 5.3 is widespreaded

Parameters
NameTypeDescription
$intoarray
Details
Access
protected  
methodprotected_attachToArray(mixed $value, string $arrayPath) : array

Converts given arrayPath to an array and attaches given value at the end of it.

Parameters
NameTypeDescription
$valuemixed

The value to attach

$arrayPathstring

Given array path to convert and attach to.

Returns
TypeDescription
array
methodprotected_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.

Parameters
NameTypeDescription
$arrayarray
$arrayPathstring | null
$keystring
Returns
TypeDescription
array
methodprotected_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').
Parameters
NameTypeDescription
$valuearray

Array to walk

$arrayPathstring

Array notation path of the part to extract

Returns
TypeDescription
string
methodprotected_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').
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
string
methodprotected_getDecorator(string $name, null | array $options) : \Zend_Form_Decorator_Interface

Instantiate a decorator based on class name or class name fragment

Parameters
NameTypeDescription
$namestring
$optionsnull | array
Returns
TypeDescription
\Zend_Form_Decorator_Interface
methodprotected_getErrorMessages() : array

Retrieve optionally translated custom error messages

Returns
TypeDescription
array
methodprotected_getIsRendered() : void

Get the value of $_isRendered member

methodprotected_loadDecorator(array $decorator, mixed $name) : \Zend_Form_Decorator_Interface

Lazy-load a decorator

Parameters
NameTypeDescription
$decoratorarray

Decorator type and options

$namemixed

Decorator name or alias

Returns
TypeDescription
\Zend_Form_Decorator_Interface
methodprotected_setElementsBelongTo(string $name = null) : void

Set array to which elements belong

Parameters
NameTypeDescription
$namestring

Element name

methodprotected_setIsRendered() : void

When calling renderFormElements or render this method is used to set $_isRendered member to prevent repeatedly merging belongsTo setting

methodprotected_sort() : void

Sort items according to their order

methodpublicaddAttribs(array $attribs) : \Zend_Form

Add multiple form attributes at once

Parameters
NameTypeDescription
$attribsarray
Returns
TypeDescription
\Zend_Form
methodpublicaddDecorator(string | \Zend_Form_Decorator_Interface $decorator, array | \Zend_Config $options = null) : \Zend_Form

Add a decorator for rendering the element

Parameters
NameTypeDescription
$decoratorstring | \Zend_Form_Decorator_Interface
$optionsarray | \Zend_Config

Options with which to initialize decorator

Returns
TypeDescription
\Zend_Form
methodpublicaddDecorators(array $decorators) : \Zend_Form

Add many decorators at once

Parameters
NameTypeDescription
$decoratorsarray
Returns
TypeDescription
\Zend_Form
methodpublicaddDisplayGroup(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.
Parameters
NameTypeDescription
$elementsarray
$namestring
$optionsarray | \Zend_Config
Returns
TypeDescription
\Zend_Form
Throws
ExceptionDescription
\Zend_Form_Exceptionif no valid elements provided
methodpublicaddDisplayGroupPrefixPath(string $prefix, string $path) : \Zend_Form

Add prefix path for all display groups

Parameters
NameTypeDescription
$prefixstring
$pathstring
Returns
TypeDescription
\Zend_Form
methodpublicaddDisplayGroupPrefixPaths(array $spec) : \Zend_Form

Add multiple display group prefix paths at once

Parameters
NameTypeDescription
$specarray
Returns
TypeDescription
\Zend_Form
methodpublicaddDisplayGroups(array $groups) : \Zend_Form

Add multiple display groups at once

Parameters
NameTypeDescription
$groupsarray
Returns
TypeDescription
\Zend_Form
methodpublicaddElement(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.
Parameters
NameTypeDescription
$elementstring | \Zend_Form_Element
$namestring
$optionsarray | \Zend_Config
Returns
TypeDescription
\Zend_Form
Throws
ExceptionDescription
\Zend_Form_Exceptionon invalid element
methodpublicaddElementPrefixPath(string $prefix, string $path, string $type = null) : \Zend_Form

Add prefix path for all elements

Parameters
NameTypeDescription
$prefixstring
$pathstring
$typestring
Returns
TypeDescription
\Zend_Form
methodpublicaddElementPrefixPaths(array $spec) : \Zend_Form

Add prefix paths for all elements

Parameters
NameTypeDescription
$specarray
Returns
TypeDescription
\Zend_Form
methodpublicaddElements(array $elements) : \Zend_Form

Add multiple elements at once

Parameters
NameTypeDescription
$elementsarray
Returns
TypeDescription
\Zend_Form
methodpublicaddError(string $message) : \Zend_Form

Add an error message and mark element as failed validation

Parameters
NameTypeDescription
$messagestring
Returns
TypeDescription
\Zend_Form
methodpublicaddErrorMessage(string $message) : \Zend_Form

Add a custom error message to return in the event of failed validation

Parameters
NameTypeDescription
$messagestring
Returns
TypeDescription
\Zend_Form
methodpublicaddErrorMessages(array $messages) : \Zend_Form

Add multiple custom error messages to return in the event of failed validation

Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form
methodpublicaddErrors(array $messages) : \Zend_Form

Add multiple error messages and flag element as failed validation

Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form
methodpublicaddPrefixPath(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/'
Parameters
NameTypeDescription
$prefixstring
$pathstring
$typestring
Returns
TypeDescription
\Zend_Form
Throws
ExceptionDescription
\Zend_Form_Exceptionfor invalid type
methodpublicaddPrefixPaths(array $spec) : \Zend_Form

Add many prefix paths at once

Parameters
NameTypeDescription
$specarray
Returns
TypeDescription
\Zend_Form
methodpublicaddSubForm(\Zend_Form $form, string $name, int $order = null) : \Zend_Form

Add a form group/subform

Parameters
NameTypeDescription
$form\Zend_Form
$namestring
$orderint
Returns
TypeDescription
\Zend_Form
methodpublicaddSubForms(array $subForms) : \Zend_Form

Add multiple form subForms/subforms at once

Parameters
NameTypeDescription
$subFormsarray
Returns
TypeDescription
\Zend_Form
methodpublicclearAttribs() : \Zend_Form

Clear all form attributes

Returns
TypeDescription
\Zend_Form
methodpublicclearDecorators() : \Zend_Form

Clear all decorators

Returns
TypeDescription
\Zend_Form
methodpublicclearDisplayGroups() : \Zend_Form

Remove all display groups

Returns
TypeDescription
\Zend_Form
methodpublicclearElements() : \Zend_Form

Remove all form elements

Returns
TypeDescription
\Zend_Form
methodpublicclearErrorMessages() : \Zend_Form

Clear custom error messages stack

Returns
TypeDescription
\Zend_Form
methodpublicclearSubForms() : \Zend_Form

Remove all form subForms/subforms

Returns
TypeDescription
\Zend_Form
methodpubliccount() : int

Count of elements/subforms that are iterable

Returns
TypeDescription
int
methodpubliccreateElement(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.).
Parameters
NameTypeDescription
$typestring
$namestring
$optionsarray | \Zend_Config
Returns
TypeDescription
\Zend_Form_Element
methodpubliccurrent() : \Zend_Form_Element | \Zend_Form_DisplayGroup | \Zend_Form

Current element/subform/display group

methodpublicfilterName(string $value, bool $allowBrackets = false) : string

Filter a name to only allow valid variable characters

Parameters
NameTypeDescription
$valuestring
$allowBracketsbool
Returns
TypeDescription
string
methodpublicgetAction() : string

Get form action

Sets default to '' if not set.
Returns
TypeDescription
string
methodpublicgetAttrib(string $key) : mixed

Retrieve a single form attribute

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublicgetAttribs() : array

Retrieve all form attributes/metadata

Returns
TypeDescription
array
methodpublicgetCustomMessages() : array

Retrieve translated custom error messages Proxies to {@link _getErrorMessages()}.

Returns
TypeDescription
array
methodpublicgetDecorator(string $name) : false | \Zend_Form_Decorator_Abstract

Retrieve a registered decorator

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
false | \Zend_Form_Decorator_Abstract
methodpublicgetDecorators() : array

Retrieve all decorators

Returns
TypeDescription
array
methodpublicgetDefaultDisplayGroupClass() : string

Retrieve default display group class

Returns
TypeDescription
string
methodpublicgetDefaultTranslator() : null | \Zend_Translate
static

Get global default translator object

Returns
TypeDescription
null | \Zend_Translate
methodpublicgetDescription() : string

Retrieve form description

Returns
TypeDescription
string
methodpublicgetDisplayGroup(string $name) : \Zend_Form_DisplayGroup | null

Return a display group

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form_DisplayGroup | null
methodpublicgetDisplayGroups() : array

Return all display groups

Returns
TypeDescription
array
methodpublicgetElement(string $name) : \Zend_Form_Element | null

Retrieve a single element

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form_Element | null
methodpublicgetElements() : array

Retrieve all elements

Returns
TypeDescription
array
methodpublicgetElementsAndSubFormsOrdered() : 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.
Returns
TypeDescription
array
Details
Access
protected  
methodpublicgetElementsBelongTo() : string | null

Get name of array elements belong to

Returns
TypeDescription
string | null
methodpublicgetEnctype() : string

Get encoding type

Returns
TypeDescription
string
methodpublicgetErrorMessages() : array

Retrieve custom error messages

Returns
TypeDescription
array
methodpublicgetErrors(string $name = null,  $suppressArrayNotation = false) : array

Get error codes for all elements failing validation

Parameters
NameTypeDescription
$namestring
$suppressArrayNotation
Returns
TypeDescription
array
methodpublicgetFullyQualifiedName() : string

Get fully qualified name

Places name as subitem of array and/or appends brackets.
Returns
TypeDescription
string
methodpublicgetId() : string

Get element id

Returns
TypeDescription
string
methodpublicgetLegend() : string

Get form legend

Returns
TypeDescription
string
methodpublicgetMessages(string $name = null, bool $suppressArrayNotation = false) : array

Retrieve error messages from elements failing validations

Parameters
NameTypeDescription
$namestring
$suppressArrayNotationbool
Returns
TypeDescription
array
methodpublicgetMethod() : string

Retrieve form method

Returns
TypeDescription
string
methodpublicgetName() : null | string

Get name attribute

Returns
TypeDescription
null | string
methodpublicgetOrder() : int | null

Get form order

Returns
TypeDescription
int | null
methodpublicgetPluginLoader(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.
Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Loader_PluginLoader_Interface
methodpublicgetSubForm(string $name) : \Zend_Form | null

Retrieve a form subForm/subform

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form | null
methodpublicgetSubForms() : array

Retrieve all form subForms/subforms

Returns
TypeDescription
array
methodpublicgetTranslator() : \Zend_Translate | null

Retrieve translator object

Returns
TypeDescription
\Zend_Translate | null
methodpublicgetUnfilteredValue(string $name) : mixed

Get unfiltered element value

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
mixed
methodpublicgetUnfilteredValues() : array

Retrieve all unfiltered element values

Returns
TypeDescription
array
methodpublicgetValidValues(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.
Parameters
NameTypeDescription
$dataarray
$suppressArrayNotationbool
Returns
TypeDescription
array
methodpublicgetValue(string $name) : mixed

Retrieve value for single element

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
mixed
methodpublicgetValues(bool $suppressArrayNotation = false) : array

Retrieve all form element values

Parameters
NameTypeDescription
$suppressArrayNotationbool
Returns
TypeDescription
array
methodpublicgetView() : \Zend_View_Interface | null

Retrieve view object

If none registered, attempts to pull from ViewRenderer.
Returns
TypeDescription
\Zend_View_Interface | null
methodpublichasDefaultTranslator() : boolean
static

Is there a default translation object set?

Returns
TypeDescription
boolean
methodpublichasErrors() : bool

Are there errors in the form?

Returns
TypeDescription
bool
methodpublichasTranslator() : bool

Does this form have its own specific translator?

Returns
TypeDescription
bool
methodpublicinit() : void

Initialize form (used by extending classes)

methodpublicisArray() : bool

Get flag indicating if elements belong to an array

Returns
TypeDescription
bool
methodpublicisErrors() : bool

Are there errors in the form?

Returns
TypeDescription
bool
Details
Deprecated
since 1.11.1 - use hasErrors() instead  
methodpublicisValid(array $data) : boolean

Validate the form

Parameters
NameTypeDescription
$dataarray
Returns
TypeDescription
boolean
methodpublicisValidPartial(array $data) : boolean

Validate a partial form

Does not check for required flags.
Parameters
NameTypeDescription
$dataarray
Returns
TypeDescription
boolean
methodpublickey() : string

Current element/subform/display group name

Returns
TypeDescription
string
methodpublicloadDefaultDecorators() : \Zend_Form

Load the default decorators

Returns
TypeDescription
\Zend_Form
methodpublicloadDefaultDecoratorsIsDisabled() : bool

Should we load the default decorators?

Returns
TypeDescription
bool
methodpublicmarkAsError() : \Zend_Form

Mark the element as being in a failed validation state

Returns
TypeDescription
\Zend_Form
methodpublicnext() : void

Move pointer to next element/subform/display group

methodpublicpersistData() : void

methodpublicpopulate(array $values) : \Zend_Form

Populate form

Proxies to {@link setDefaults()}
Parameters
NameTypeDescription
$valuesarray
Returns
TypeDescription
\Zend_Form
methodpublicprocessAjax(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()}).
Parameters
NameTypeDescription
$dataarray
Returns
TypeDescription
stringJSON-encoded boolean true or error messages
methodpublicremoveAttrib(string $key) : bool

Remove attribute

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
bool
methodpublicremoveDecorator(string $name) : bool

Remove a single decorator

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
bool
methodpublicremoveDisplayGroup(string $name) : boolean

Remove a display group by name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
boolean
methodpublicremoveElement(string $name) : boolean

Remove element

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
boolean
methodpublicremoveFromIteration(string $name) : void

Remove an element from iteration

Parameters
NameTypeDescription
$namestring

Element/group/form name

methodpublicremoveSubForm(string $name) : boolean

Remove form subForm/subform

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
boolean
methodpublicrender(\Zend_View_Interface $view = null) : string

Render form

Parameters
NameTypeDescription
$view\Zend_View_Interface
Returns
TypeDescription
string
methodpublicreset() : \Zend_Form

Reset values of form

Returns
TypeDescription
\Zend_Form
methodpublicrewind() : void

Move pointer to beginning of element/subform/display group loop

methodpublicsetAction(string $action) : \Zend_Form

Set form action

Parameters
NameTypeDescription
$actionstring
Returns
TypeDescription
\Zend_Form
methodpublicsetAttrib(string $key, mixed $value) : \Zend_Form

Set form attribute

Parameters
NameTypeDescription
$keystring
$valuemixed
Returns
TypeDescription
\Zend_Form
methodpublicsetAttribs(array $attribs) : \Zend_Form

Set multiple form attributes at once

Overwrites any previously set attributes.
Parameters
NameTypeDescription
$attribsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetConfig(\Zend_Config $config) : \Zend_Form

Set form state from config object

Parameters
NameTypeDescription
$config\Zend_Config
Returns
TypeDescription
\Zend_Form
methodpublicsetDecorators(array $decorators) : \Zend_Form

Overwrite all decorators

Parameters
NameTypeDescription
$decoratorsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetDefault(string $name, mixed $value) : \Zend_Form

Set default value for an element

Parameters
NameTypeDescription
$namestring
$valuemixed
Returns
TypeDescription
\Zend_Form
methodpublicsetDefaultDisplayGroupClass(string $class) : \Zend_Form

Set default display group class

Parameters
NameTypeDescription
$classstring
Returns
TypeDescription
\Zend_Form
methodpublicsetDefaultTranslator(\Zend_Translate | \Zend_Translate_Adapter | null $translator = null) : void
static

Set global default translator object

Parameters
NameTypeDescription
$translator\Zend_Translate | \Zend_Translate_Adapter | null
methodpublicsetDefaults(array $defaults) : \Zend_Form

Set default values for elements

Sets values for all elements specified in the array of $defaults.
Parameters
NameTypeDescription
$defaultsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetDescription(string $value) : \Zend_Form

Set form description

Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Form
methodpublicsetDisableLoadDefaultDecorators(bool $flag) : \Zend_Form

Set flag to disable loading default decorators

Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form
methodpublicsetDisableTranslator(bool $flag) : \Zend_Form

Indicate whether or not translation should be disabled

Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form
methodpublicsetDisplayGroupDecorators(array $decorators) : \Zend_Form

Set all display group decorators as specified

Parameters
NameTypeDescription
$decoratorsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetDisplayGroups(array $groups) : \Zend_Form

Add multiple display groups (overwrites)

Parameters
NameTypeDescription
$groupsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetElementDecorators(array $decorators, array | null $elements = null, bool $include = true) : \Zend_Form

Set all element decorators as specified

Parameters
NameTypeDescription
$decoratorsarray
$elementsarray | null

Specific elements to decorate or exclude from decoration

$includebool

Whether $elements is an inclusion or exclusion list

Returns
TypeDescription
\Zend_Form
methodpublicsetElementFilters(array $filters) : \Zend_Form

Set all elements' filters

Parameters
NameTypeDescription
$filtersarray
Returns
TypeDescription
\Zend_Form
methodpublicsetElements(array $elements) : \Zend_Form

Set form elements (overwrites existing elements)

Parameters
NameTypeDescription
$elementsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetElementsBelongTo(string $array) : \Zend_Form

Set name of array elements belong to

Parameters
NameTypeDescription
$arraystring
Returns
TypeDescription
\Zend_Form
methodpublicsetEnctype(string $value) : \Zend_Form

Set encoding type

Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Form
methodpublicsetErrorMessages(array $messages) : \Zend_Form

Same as addErrorMessages(), but clears custom error message stack first

Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form
methodpublicsetErrors(array $messages) : \Zend_Form

Overwrite any previously set error messages and flag as failed validation

Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form
methodpublicsetIsArray(bool $flag) : \Zend_Form

Set flag indicating elements belong to array

Parameters
NameTypeDescription
$flagbool

Value of flag

Returns
TypeDescription
\Zend_Form
methodpublicsetLegend(string $value) : \Zend_Form

Set form legend

Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Form
methodpublicsetMethod(string $method) : \Zend_Form

Set form method

Only values in {@link $_methods()} allowed
Parameters
NameTypeDescription
$methodstring
Returns
TypeDescription
\Zend_Form
Throws
ExceptionDescription
\Zend_Form_Exception
methodpublicsetName(string $name) : \Zend_Form

Set form name

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form
methodpublicsetOptions(array $options) : \Zend_Form

Set form state from options array

Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetOrder(int $index) : \Zend_Form

Set form order

Parameters
NameTypeDescription
$indexint
Returns
TypeDescription
\Zend_Form
methodpublicsetPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type = null) : \Zend_Form

Set plugin loaders for use with decorators and elements

Parameters
NameTypeDescription
$loader\Zend_Loader_PluginLoader_Interface
$typestring

'decorator' or 'element'

Returns
TypeDescription
\Zend_Form
Throws
ExceptionDescription
\Zend_Form_Exceptionon invalid type
methodpublicsetSubFormDecorators(array $decorators) : \Zend_Form

Set all subform decorators as specified

Parameters
NameTypeDescription
$decoratorsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetSubForms(array $subForms) : \Zend_Form

Set multiple form subForms/subforms (overwrites)

Parameters
NameTypeDescription
$subFormsarray
Returns
TypeDescription
\Zend_Form
methodpublicsetTranslator(\Zend_Translate | \Zend_Translate_Adapter | null $translator = null) : \Zend_Form

Set translator object

Parameters
NameTypeDescription
$translator\Zend_Translate | \Zend_Translate_Adapter | null
Returns
TypeDescription
\Zend_Form
methodpublicsetView(\Zend_View_Interface $view = null) : \Zend_Form

Set view object

Parameters
NameTypeDescription
$view\Zend_View_Interface
Returns
TypeDescription
\Zend_Form
methodpublictranslatorIsDisabled() : bool

Is translation disabled?

Returns
TypeDescription
bool
methodpublicvalid() : bool

Determine if current element/subform/display group is valid

Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.2.0 .