Form/Element/Xhtml.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 [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Form
- Subpackage
- Element
\Zend_Form_Element_Xhtml
Base element for XHTML elements
- Parent(s)
- \Zend_Form_Element
- Children
- \Zend_Form_Element_Hidden
- \Zend_Form_Element_Text
- \Zend_Form_Element_Checkbox
- \Zend_Form_Element_File
- \Zend_Form_Element_Image
- \Zend_Form_Element_Password
- \Zend_Form_Element_Submit
- \Zend_Form_Element_Captcha
- \Zend_Form_Element_Hash
- \Zend_Form_Element_Multi
- \Zend_Form_Element_Textarea
- \Zend_Form_Element_Note
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Version
- $Id: Xhtml.php 24593 2012-01-05 20:35:02Z matthew $
Constants

FILTER
= 'FILTER'
- Inherited_from
- \Zend_Form_Element::FILTER

VALIDATE
= 'VALIDATE'
- Inherited_from
- \Zend_Form_Element::VALIDATE
Properties


bool $_allowEmpty = true
true
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_allowEmpty


bool $_autoInsertNotEmptyValidator = true
Flag indicating whether or not to insert NotEmpty validator when element is required
Inherited from: \Zend_Form_Element::$$_autoInsertNotEmptyValidatortrue
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_autoInsertNotEmptyValidator


array $_decorators = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_decorators


bool $_disableLoadDefaultDecorators = false
Should we disable loading the default decorators?
Inherited from: \Zend_Form_Element::$$_disableLoadDefaultDecoratorsfalse
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_disableLoadDefaultDecorators


string $_errorMessageSeparator = '; '
Separator to use when concatenating aggregate error messages (for elements having array values)
Inherited from: \Zend_Form_Element::$$_errorMessageSeparator'; '
Details- Type
- string
- Inherited_from
- \Zend_Form_Element::$$_errorMessageSeparator


array $_errorMessages = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_errorMessages


array $_errors = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_errors


array $_filters = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_filters


bool $_ignore = false
Ignore flag (used when retrieving values at form level)
Inherited from: \Zend_Form_Element::$$_ignorefalse
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_ignore


bool $_isArray = false
false
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_isArray


bool $_isError = false
false
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_isError


bool $_isErrorForced = false
Has the element been manually marked as invalid?
Inherited from: \Zend_Form_Element::$$_isErrorForcedfalse
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_isErrorForced


bool $_isPartialRendering = false
Is a specific decorator being rendered via the magic renderDecorator()?
Inherited from: \Zend_Form_Element::$$_isPartialRenderingThis is to allow execution of logic inside the render() methods of child elements during the magic call while skipping the parent render() method.
false
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_isPartialRendering


array $_loaders = array()
Plugin loaders for filter and validator chains
Inherited from: \Zend_Form_Element::$$_loadersarray()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_loaders


array $_messages = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_messages


bool $_required = false
false
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_required


\Zend_Translate $_translator =
- Type
- \Zend_Translate
- Inherited_from
- \Zend_Form_Element::$$_translator


bool $_translatorDisabled = false
false
Details- Type
- bool
- Inherited_from
- \Zend_Form_Element::$$_translatorDisabled


array $_validatorRules = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_validatorRules


array $_validators = array()
Array of initialized validators
<p>Validators</p>Inherited from: \Zend_Form_Element::$$_validatorsarray()
Details- Type
- array
- Inherited_from
- \Zend_Form_Element::$$_validators


\Zend_View_Interface $_view =
- Type
- \Zend_View_Interface
- Inherited_from
- \Zend_Form_Element::$$_view


string $helper = 'formText'
'formText'
Details- Type
- string
- Inherited_from
- \Zend_Form_Element::$$helper
Methods


__call(string $method, array $args) : string
Overloading: allow rendering specific decorators
Inherited from: \Zend_Form_Element::__call()Call renderDecoratorName() to render a specific decorator.
Name | Type | Description |
---|---|---|
$method | string | |
$args | array |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Form_Exception | for invalid decorator or invalid method call |


__construct(string | array | \Zend_Config $spec, array | \Zend_Config $options = null) : void
$spec may be: - string: name of element - array: options with which to configure element - Zend_Config: Zend_Config with options for configuring element
Name | Type | Description |
---|---|---|
$spec | string | array | \Zend_Config | |
$options | array | \Zend_Config |
Exception | Description |
---|---|
\Zend_Form_Exception | if no element name after initialization |


__get(string $key) : mixed
Prevents access to properties beginning with '_'.
Name | Type | Description |
---|---|---|
$key | string |
Type | Description |
---|---|
mixed |


__set(string $key, mixed $value) : \voide
Name | Type | Description |
---|---|---|
$key | string | |
$value | mixed |
Type | Description |
---|---|
\voide |


_filterValue(string $value, string $key) : void
Name | Type | Description |
---|---|---|
$value | string | |
$key | string |


_getDecorator(string $name, null | array $options) : \Zend_Form_Decorator_Interface
Instantiate a decorator based on class name or class name fragment
Inherited from: \Zend_Form_Element::_getDecorator()Name | Type | Description |
---|---|---|
$name | string | |
$options | null | array |
Type | Description |
---|---|
\Zend_Form_Decorator_Interface |


_getErrorMessages() : array
Retrieve error messages and perform translation and value substitution
Inherited from: \Zend_Form_Element::_getErrorMessages()Type | Description |
---|---|
array |


_hasErrorMessages() : bool
Are there custom error messages registered?
Inherited from: \Zend_Form_Element::_hasErrorMessages()Type | Description |
---|---|
bool |


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


_loadFilter(array $filter) : \Zend_Filter_Interface
Name | Type | Description |
---|---|---|
$filter | array |
Type | Description |
---|---|
\Zend_Filter_Interface |


_loadValidator(array $validator) : \Zend_Validate_Interface
Name | Type | Description |
---|---|---|
$validator | array | Validator definition |
Type | Description |
---|---|
\Zend_Validate_Interface |


addDecorator(string | \Zend_Form_Decorator_Interface $decorator, array | \Zend_Config $options = null) : \Zend_Form_Element
Add a decorator for rendering the element
Inherited from: \Zend_Form_Element::addDecorator()Name | Type | Description |
---|---|---|
$decorator | string | \Zend_Form_Decorator_Interface | |
$options | array | \Zend_Config | Options with which to initialize decorator |
Type | Description |
---|---|
\Zend_Form_Element |


addDecorators(array $decorators) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$decorators | array |
Type | Description |
---|---|
\Zend_Form_Element |


addError(string $message) : \Zend_Form_Element
Add an error message and mark element as failed validation
Inherited from: \Zend_Form_Element::addError()Name | Type | Description |
---|---|---|
$message | string |
Type | Description |
---|---|
\Zend_Form_Element |


addErrorMessage(string $message) : \Zend_Form_Element
Add a custom error message to return in the event of failed validation
Inherited from: \Zend_Form_Element::addErrorMessage()Name | Type | Description |
---|---|---|
$message | string |
Type | Description |
---|---|
\Zend_Form_Element |


addErrorMessages(array $messages) : \Zend_Form_Element
Add multiple custom error messages to return in the event of failed validation
Inherited from: \Zend_Form_Element::addErrorMessages()Name | Type | Description |
---|---|---|
$messages | array |
Type | Description |
---|---|
\Zend_Form_Element |


addErrors(array $messages) : \Zend_Form_Element
Add multiple error messages and flag element as failed validation
Inherited from: \Zend_Form_Element::addErrors()Name | Type | Description |
---|---|---|
$messages | array |
Type | Description |
---|---|
\Zend_Form_Element |


addFilter(string | \Zend_Filter_Interface $filter, $options = array()) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$filter | string | \Zend_Filter_Interface | |
$options |
Type | Description |
---|---|
\Zend_Form_Element |


addFilters(array $filters) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$filters | array |
Type | Description |
---|---|
\Zend_Form_Element |


addPrefixPath(string $prefix, string $path, string $type = null) : \Zend_Form_Element
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' - filters: $prefix = $prefix . '_Filter' - validators: $prefix = $prefix . '_Validate'
Otherwise, the path prefix is set on the appropriate plugin loader.
Name | Type | Description |
---|---|---|
$prefix | string | |
$path | string | |
$type | string |
Type | Description |
---|---|
\Zend_Form_Element |
Exception | Description |
---|---|
\Zend_Form_Exception | for invalid type |


addPrefixPaths(array $spec) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$spec | array |
Type | Description |
---|---|
\Zend_Form_Element |


addValidator(string | \Zend_Validate_Interface $validator, bool $breakChainOnFailure = false, array $options = array()) : \Zend_Form_Element
Note: will overwrite existing validators if they are of the same class.
Name | Type | Description |
---|---|---|
$validator | string | \Zend_Validate_Interface | |
$breakChainOnFailure | bool | |
$options | array |
Type | Description |
---|---|
\Zend_Form_Element |
Exception | Description |
---|---|
\Zend_Form_Exception | if invalid validator type |


addValidators(array $validators) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$validators | array |
Type | Description |
---|---|
\Zend_Form_Element |


autoInsertNotEmptyValidator() : bool
Get flag indicating whether a NotEmpty validator should be inserted when element is required
Inherited from: \Zend_Form_Element::autoInsertNotEmptyValidator()Type | Description |
---|---|
bool |


filterName(string $value, bool $allowBrackets = false) : string
Filter a name to only allow valid variable characters
Inherited from: \Zend_Form_Element::filterName()Name | Type | Description |
---|---|---|
$value | string | |
$allowBrackets | bool |
Type | Description |
---|---|
string |


getAttrib(string $name) : string
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string |


getBelongsTo() : string
Return array name to which element belongs
Inherited from: \Zend_Form_Element::getBelongsTo()Type | Description |
---|---|
string |


getDecorator(string $name) : false | \Zend_Form_Decorator_Abstract
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
false | \Zend_Form_Decorator_Abstract |


getFilter(string $name) : \Zend_Filter_Interface
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Filter_Interface |


getFullyQualifiedName() : string
Places name as subitem of array and/or appends brackets.
Type | Description |
---|---|
string |


getIgnore() : bool
Get ignore flag (used when retrieving values at form level)
Inherited from: \Zend_Form_Element::getIgnore()Type | Description |
---|---|
bool |


getMessages() : array
The array keys are validation failure message identifiers, and the array values are the corresponding human-readable message strings.
If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.
Type | Description |
---|---|
array |


getPluginLoader(string $type) : \Zend_Loader_PluginLoader
Retrieve plugin loader for validator or filter chain
Inherited from: \Zend_Form_Element::getPluginLoader()Instantiates with default rules if none available for that type. Use 'decorator', 'filter', or 'validate' for $type.
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
\Zend_Loader_PluginLoader |
Exception | Description |
---|---|
\Zend_Loader_Exception | on invalid type. |


getTranslator() : \Zend_Translate_Adapter | null
Retrieve localization translator object
Inherited from: \Zend_Form_Element::getTranslator()Type | Description |
---|---|
\Zend_Translate_Adapter | null |


getValidator(string $name) : \Zend_Validate_Interface | false
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Validate_Interface | false | False if not found, validator otherwise |


getView() : null | \Zend_View_Interface
Retrieves from ViewRenderer if none previously set.
Type | Description |
---|---|
null | \Zend_View_Interface |


hasTranslator() : bool
Does this element have its own specific translator?
Inherited from: \Zend_Form_Element::hasTranslator()Type | Description |
---|---|
bool |


isValid(mixed $value, mixed $context = null) : boolean
If a translation adapter is registered, any error messages will be translated according to the current locale, using the given error code; if no matching translation is found, the original message will be utilized.
Note: The filtered value is validated.
Name | Type | Description |
---|---|---|
$value | mixed | |
$context | mixed |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Validate_Exception | If validation of $value is impossible |


loadDefaultDecoratorsIsDisabled() : bool
Should we load the default decorators?
Inherited from: \Zend_Form_Element::loadDefaultDecoratorsIsDisabled()Type | Description |
---|---|
bool |


markAsError() : \Zend_Form_Element
Mark the element as being in a failed validation state
Inherited from: \Zend_Form_Element::markAsError()Type | Description |
---|---|
\Zend_Form_Element |


removeDecorator(string $name) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Form_Element |


removeFilter(string $name) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Form_Element |


removeValidator(string $name) : bool
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
bool |


render(\Zend_View_Interface $view = null) : string
Name | Type | Description |
---|---|---|
$view | \Zend_View_Interface |
Type | Description |
---|---|
string |


resolveElementId(\Zend_Form_Decorator_Interface $decorator) : string
Used to resolve and return an element ID
Inherited from: \Zend_Form_Element::resolveElementId()Passed to the HtmlTag decorator as a callback in order to provide an ID.
Name | Type | Description |
---|---|---|
$decorator | \Zend_Form_Decorator_Interface |
Type | Description |
---|---|
string |


setAllowEmpty(bool $flag) : \Zend_Form_Element
When the allow empty flag is enabled and the required flag is false, the element will validate with empty values.
Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Form_Element |


setAttrib(string $name, mixed $value) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$name | string | |
$value | mixed |
Type | Description |
---|---|
\Zend_Form_Element |
Exception | Description |
---|---|
\Zend_Form_Exception | for invalid $name values |


setAttribs(array $attribs) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$attribs | array |
Type | Description |
---|---|
\Zend_Form_Element |


setAutoInsertNotEmptyValidator(bool $flag) : \Zend_Form_Element
Set flag indicating whether a NotEmpty validator should be inserted when element is required
Inherited from: \Zend_Form_Element::setAutoInsertNotEmptyValidator()Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Form_Element |


setBelongsTo(string $array) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$array | string |
Type | Description |
---|---|
\Zend_Form_Element |


setConfig(\Zend_Config $config) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$config | \Zend_Config |
Type | Description |
---|---|
\Zend_Form_Element |


setDecorators(array $decorators) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$decorators | array |
Type | Description |
---|---|
\Zend_Form_Element |


setDescription(string $description) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$description | string |
Type | Description |
---|---|
\Zend_Form_Element |


setDisableLoadDefaultDecorators(bool $flag) : \Zend_Form_Element
Set flag to disable loading default decorators
Inherited from: \Zend_Form_Element::setDisableLoadDefaultDecorators()Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Form_Element |


setDisableTranslator(bool $flag) : \Zend_Form_Element
Indicate whether or not translation should be disabled
Inherited from: \Zend_Form_Element::setDisableTranslator()Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Form_Element |


setErrorMessageSeparator(string $separator) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$separator | string |
Type | Description |
---|---|
\Zend_Form_Element |


setErrorMessages(array $messages) : \Zend_Form_Element
Same as addErrorMessages(), but clears custom error message stack first
Inherited from: \Zend_Form_Element::setErrorMessages()Name | Type | Description |
---|---|---|
$messages | array |
Type | Description |
---|---|
\Zend_Form_Element |


setErrors(array $messages) : \Zend_Form_Element
Overwrite any previously set error messages and flag as failed validation
Inherited from: \Zend_Form_Element::setErrors()Name | Type | Description |
---|---|---|
$messages | array |
Type | Description |
---|---|
\Zend_Form_Element |


setFilters(array $filters) : \Zend_Form_Element
Add filters to element, overwriting any already existing
Inherited from: \Zend_Form_Element::setFilters()Name | Type | Description |
---|---|---|
$filters | array |
Type | Description |
---|---|
\Zend_Form_Element |


setIgnore(bool $flag) : \Zend_Form_Element
Set ignore flag (used when retrieving values at form level)
Inherited from: \Zend_Form_Element::setIgnore()Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Form_Element |


setIsArray(bool $flag) : \Zend_Form_Element
Set flag indicating if element represents an array
Inherited from: \Zend_Form_Element::setIsArray()Name | Type | Description |
---|---|---|
$flag | bool |
Type | Description |
---|---|
\Zend_Form_Element |


setLabel(string $label) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$label | string |
Type | Description |
---|---|
\Zend_Form_Element |


setName(string $name) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
\Zend_Form_Element |


setOptions(array $options) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Form_Element |


setOrder(int $order) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$order | int |
Type | Description |
---|---|
\Zend_Form_Element |


setPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_Form_Element
Set plugin loader to use for validator or filter chain
Inherited from: \Zend_Form_Element::setPluginLoader()Name | Type | Description |
---|---|---|
$loader | \Zend_Loader_PluginLoader_Interface | |
$type | string | 'decorator', 'filter', or 'validate' |
Type | Description |
---|---|
\Zend_Form_Element |
Exception | Description |
---|---|
\Zend_Form_Exception | on invalid type |


setRequired(bool $flag = true) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$flag | bool | Default value is true |
Type | Description |
---|---|
\Zend_Form_Element |


setTranslator(\Zend_Translate | null $translator = null) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$translator | \Zend_Translate | null |
Type | Description |
---|---|
\Zend_Form_Element |


setValidators(array $validators) : \Zend_Form_Element
Set multiple validators, overwriting previous validators
Inherited from: \Zend_Form_Element::setValidators()Name | Type | Description |
---|---|---|
$validators | array |
Type | Description |
---|---|
\Zend_Form_Element |


setValue(mixed $value) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$value | mixed |
Type | Description |
---|---|
\Zend_Form_Element |


setView(\Zend_View_Interface $view = null) : \Zend_Form_Element
Name | Type | Description |
---|---|---|
$view | \Zend_View_Interface |
Type | Description |
---|---|
\Zend_Form_Element |