Form/Element/Multiselect.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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Form  
Subpackage
Element  

\Zend_Form_Element_Multiselect

Package: Zend\Form\Element
Multiselect form element
Parent(s)
\Zend_Form_Element_Select < \Zend_Form_Element_Multi < \Zend_Form_Element_Xhtml < \Zend_Form_Element
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Version
$Id: Multiselect.php 24593 2012-01-05 20:35:02Z matthew $  

Constants

Properties

>VPropertyprotectedstring $_errorMessageSeparator = '; '
>VPropertyprotectedbool $_ignore = false
Default valuefalseDetails
Type
bool
Inherited_from
\Zend_Form_Element::$$_ignore  
Inherited_from
\Zend_Form_Element_Xhtml::$$_ignore  
Inherited_from
\Zend_Form_Element_Multi::$$_ignore  
Inherited_from
\Zend_Form_Element_Select::$$_ignore  
>VPropertyprotectedbool $_isArray = true
Multiselect is an array of values by default
Default valuetrueDetails
Type
bool
>VPropertyprotectedbool $_isError = false
Default valuefalseDetails
Type
bool
Inherited_from
\Zend_Form_Element::$$_isError  
Inherited_from
\Zend_Form_Element_Xhtml::$$_isError  
Inherited_from
\Zend_Form_Element_Multi::$$_isError  
Inherited_from
\Zend_Form_Element_Select::$$_isError  
>VPropertyprotectedbool $_isPartialRendering = false

This is to allow execution of logic inside the render() methods of child elements during the magic call while skipping the parent render() method.

Default valuefalseDetails
Type
bool
Inherited_from
\Zend_Form_Element::$$_isPartialRendering  
Inherited_from
\Zend_Form_Element_Xhtml::$$_isPartialRendering  
Inherited_from
\Zend_Form_Element_Multi::$$_isPartialRendering  
Inherited_from
\Zend_Form_Element_Select::$$_isPartialRendering  
>VPropertyprotectedarray $_loaders = array()
Default valuearray()Details
Type
array
Inherited_from
\Zend_Form_Element::$$_loaders  
Inherited_from
\Zend_Form_Element_Xhtml::$$_loaders  
Inherited_from
\Zend_Form_Element_Multi::$$_loaders  
Inherited_from
\Zend_Form_Element_Select::$$_loaders  
>VPropertyprotectedarray $_messages = array()
Default valuearray()Details
Type
array
Inherited_from
\Zend_Form_Element::$$_messages  
Inherited_from
\Zend_Form_Element_Xhtml::$$_messages  
Inherited_from
\Zend_Form_Element_Multi::$$_messages  
Inherited_from
\Zend_Form_Element_Select::$$_messages  
>VPropertyprotectedbool $_registerInArrayValidator = true
>VPropertyprotectedstring $_separator = '<br />'
inherited
Separator to use between options; defaults to '
'.
Inherited from: \Zend_Form_Element_Multi::$$_separator\Zend_Form_Element_Select::$$_separator
Default value'<br />'Details
Type
string
Inherited_from
\Zend_Form_Element_Multi::$$_separator  
Inherited_from
\Zend_Form_Element_Select::$$_separator  
>VPropertyprotectedarray $_translated = array()
inherited
Which values are translated already?
Inherited from: \Zend_Form_Element_Multi::$$_translated\Zend_Form_Element_Select::$$_translated
Default valuearray()Details
Type
array
Inherited_from
\Zend_Form_Element_Multi::$$_translated  
Inherited_from
\Zend_Form_Element_Select::$$_translated  
>VPropertypublicstring $helper = 'formSelect'
Use formSelect view helper by default
Default value'formSelect'Details
Type
string
>VPropertypublicstring $multiple = 'multiple'
'multiple' attribute
Default value'multiple'Details
Type
string
>VPropertypublicarray $options = array()
inherited
Array of options for multi-item
Inherited from: \Zend_Form_Element_Multi::$$options\Zend_Form_Element_Select::$$options
Default valuearray()Details
Type
array
Inherited_from
\Zend_Form_Element_Multi::$$options  
Inherited_from
\Zend_Form_Element_Select::$$options  

Methods

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

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__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

Parameters
NameTypeDescription
$specstring | array | \Zend_Config
$optionsarray | \Zend_Config
Throws
ExceptionDescription
\Zend_Form_Exceptionif no element name after initialization
methodpublic__get(string $key) : mixed

Prevents access to properties beginning with '_'.

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublic__set(string $key, mixed $value) : \voide
Parameters
NameTypeDescription
$keystring
$valuemixed
Returns
TypeDescription
\voide
methodpublic__toString() : string

Proxies to render().

Returns
TypeDescription
string
methodprotected_filterValue(string $value, string $key) : void
Parameters
NameTypeDescription
$valuestring
$keystring
methodprotected_getDecorator(string $name, null | array $options) : \Zend_Form_Decorator_Interface
Parameters
NameTypeDescription
$namestring
$optionsnull | array
Returns
TypeDescription
\Zend_Form_Decorator_Interface
methodprotected_getErrorMessages() : array
Returns
TypeDescription
array
methodprotected_getMultiOptions() : array
Returns
TypeDescription
array
methodprotected_hasErrorMessages() : bool
Returns
TypeDescription
bool
methodprotected_loadDecorator(array $decorator, mixed $name) : \Zend_Form_Decorator_Interface
Parameters
NameTypeDescription
$decoratorarray

Decorator type and options

$namemixed

Decorator name or alias

Returns
TypeDescription
\Zend_Form_Decorator_Interface
methodprotected_loadFilter(array $filter) : \Zend_Filter_Interface
Parameters
NameTypeDescription
$filterarray
Returns
TypeDescription
\Zend_Filter_Interface
methodprotected_loadValidator(array $validator) : \Zend_Validate_Interface
Parameters
NameTypeDescription
$validatorarray

Validator definition

Returns
TypeDescription
\Zend_Validate_Interface
methodprotected_translateOption(string $option, string $value) : bool
Parameters
NameTypeDescription
$optionstring
$valuestring
Returns
TypeDescription
bool
methodprotected_translateValue(string $value) : string
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
string
methodpublicaddDecorator(string | \Zend_Form_Decorator_Interface $decorator, array | \Zend_Config $options = null) : \Zend_Form_Element
Parameters
NameTypeDescription
$decoratorstring | \Zend_Form_Decorator_Interface
$optionsarray | \Zend_Config

Options with which to initialize decorator

Returns
TypeDescription
\Zend_Form_Element
methodpublicaddDecorators(array $decorators) : \Zend_Form_Element
Parameters
NameTypeDescription
$decoratorsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddError(string $message) : \Zend_Form_Element
Parameters
NameTypeDescription
$messagestring
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddErrorMessage(string $message) : \Zend_Form_Element
Parameters
NameTypeDescription
$messagestring
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddErrorMessages(array $messages) : \Zend_Form_Element
Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddErrors(array $messages) : \Zend_Form_Element
Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddFilter(string | \Zend_Filter_Interface $filter,  $options = array()) : \Zend_Form_Element
Parameters
NameTypeDescription
$filterstring | \Zend_Filter_Interface
$options
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddFilters(array $filters) : \Zend_Form_Element
Parameters
NameTypeDescription
$filtersarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddMultiOption(string $option, string $value = '') : \Zend_Form_Element_Multi
Parameters
NameTypeDescription
$optionstring
$valuestring
Returns
TypeDescription
\Zend_Form_Element_Multi
methodpublicaddMultiOptions(array $options) : \Zend_Form_Element_Multi
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Form_Element_Multi
methodpublicaddPrefixPath(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.

Parameters
NameTypeDescription
$prefixstring
$pathstring
$typestring
Returns
TypeDescription
\Zend_Form_Element
Throws
ExceptionDescription
\Zend_Form_Exceptionfor invalid type
methodpublicaddPrefixPaths(array $spec) : \Zend_Form_Element
Parameters
NameTypeDescription
$specarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicaddValidator(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.

Parameters
NameTypeDescription
$validatorstring | \Zend_Validate_Interface
$breakChainOnFailurebool
$optionsarray
Returns
TypeDescription
\Zend_Form_Element
Throws
ExceptionDescription
\Zend_Form_Exceptionif invalid validator type
methodpublicaddValidators(array $validators) : \Zend_Form_Element
Parameters
NameTypeDescription
$validatorsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicautoInsertNotEmptyValidator() : bool
Returns
TypeDescription
bool
methodpublicfilterName(string $value, bool $allowBrackets = false) : string
Parameters
NameTypeDescription
$valuestring
$allowBracketsbool
Returns
TypeDescription
string
methodpublicgetAttrib(string $name) : string
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string
methodpublicgetBelongsTo() : string
Returns
TypeDescription
string
methodpublicgetDecorator(string $name) : false | \Zend_Form_Decorator_Abstract
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
false | \Zend_Form_Decorator_Abstract
methodpublicgetErrors() : array
Returns
TypeDescription
array
methodpublicgetFilter(string $name) : \Zend_Filter_Interface
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Filter_Interface
methodpublicgetFullyQualifiedName() : string

Places name as subitem of array and/or appends brackets.

Returns
TypeDescription
string
methodpublicgetIgnore() : bool
Returns
TypeDescription
bool
methodpublicgetLabel() : string
Returns
TypeDescription
string
methodpublicgetMessages() : 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.

Returns
TypeDescription
array
methodpublicgetMultiOption(string $option) : mixed
Parameters
NameTypeDescription
$optionstring
Returns
TypeDescription
mixed
methodpublicgetMultiOptions() : array
Returns
TypeDescription
array
methodpublicgetName() : string
Returns
TypeDescription
string
methodpublicgetPluginLoader(string $type) : \Zend_Loader_PluginLoader

Instantiates with default rules if none available for that type. Use 'decorator', 'filter', or 'validate' for $type.

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Loader_PluginLoader
Throws
ExceptionDescription
\Zend_Loader_Exceptionon invalid type.
methodpublicgetSeparator() : mixed
Returns
TypeDescription
mixed
methodpublicgetType() : string
Returns
TypeDescription
string
methodpublicgetValidator(string $name) : \Zend_Validate_Interface | false
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Validate_Interface | falseFalse if not found, validator otherwise
methodpublicgetValue() : mixed
Returns
TypeDescription
mixed
methodpublicgetView() : null | \Zend_View_Interface

Retrieves from ViewRenderer if none previously set.

Returns
TypeDescription
null | \Zend_View_Interface
methodpublichasErrors() : bool
Returns
TypeDescription
bool
methodpublichasTranslator() : bool
Returns
TypeDescription
bool
methodpublicinit() : void
methodpublicisArray() : bool
Returns
TypeDescription
bool
methodpublicisValid(string $value, mixed $context = null) : bool
inherited

Is the value provided valid?

Inherited from: \Zend_Form_Element_Multi::isValid()\Zend_Form_Element_Select::isValid()

Autoregisters InArray validator if necessary.

Parameters
NameTypeDescription
$valuestring
$contextmixed
Returns
TypeDescription
bool
Throws
ExceptionDescription
\Zend_Validate_ExceptionIf validation of $value is impossible
methodpublicregisterInArrayValidator() : bool
inherited

Get status of auto-register inArray validator flag

Inherited from: \Zend_Form_Element_Multi::registerInArrayValidator()\Zend_Form_Element_Select::registerInArrayValidator()
Returns
TypeDescription
bool
methodpublicremoveDecorator(string $name) : \Zend_Form_Element
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form_Element
methodpublicremoveFilter(string $name) : \Zend_Form_Element
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form_Element
methodpublicremoveMultiOption(string $option) : bool
Parameters
NameTypeDescription
$optionstring
Returns
TypeDescription
bool
methodpublicremoveValidator(string $name) : bool
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
bool
methodpublicrender(\Zend_View_Interface $view = null) : string
Parameters
NameTypeDescription
$view\Zend_View_Interface
Returns
TypeDescription
string
methodpublicresolveElementId(\Zend_Form_Decorator_Interface $decorator) : string

Passed to the HtmlTag decorator as a callback in order to provide an ID.

Parameters
NameTypeDescription
$decorator\Zend_Form_Decorator_Interface
Returns
TypeDescription
string
methodpublicsetAllowEmpty(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.

Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetAttrib(string $name, mixed $value) : \Zend_Form_Element
Parameters
NameTypeDescription
$namestring
$valuemixed
Returns
TypeDescription
\Zend_Form_Element
Throws
ExceptionDescription
\Zend_Form_Exceptionfor invalid $name values
methodpublicsetAttribs(array $attribs) : \Zend_Form_Element
Parameters
NameTypeDescription
$attribsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetAutoInsertNotEmptyValidator(bool $flag) : \Zend_Form_Element
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetBelongsTo(string $array) : \Zend_Form_Element
Parameters
NameTypeDescription
$arraystring
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetConfig(\Zend_Config $config) : \Zend_Form_Element
Parameters
NameTypeDescription
$config\Zend_Config
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetDecorators(array $decorators) : \Zend_Form_Element
Parameters
NameTypeDescription
$decoratorsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetDescription(string $description) : \Zend_Form_Element
Parameters
NameTypeDescription
$descriptionstring
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetDisableLoadDefaultDecorators(bool $flag) : \Zend_Form_Element
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetDisableTranslator(bool $flag) : \Zend_Form_Element
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetErrorMessageSeparator(string $separator) : \Zend_Form_Element
Parameters
NameTypeDescription
$separatorstring
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetErrorMessages(array $messages) : \Zend_Form_Element
Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetErrors(array $messages) : \Zend_Form_Element
inherited

Overwrite any previously set error messages and flag as failed validation

Inherited from: \Zend_Form_Element::setErrors()\Zend_Form_Element_Xhtml::setErrors()\Zend_Form_Element_Multi::setErrors()\Zend_Form_Element_Select::setErrors()
Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetFilters(array $filters) : \Zend_Form_Element
Parameters
NameTypeDescription
$filtersarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetIgnore(bool $flag) : \Zend_Form_Element
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetIsArray(bool $flag) : \Zend_Form_Element
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetLabel(string $label) : \Zend_Form_Element
Parameters
NameTypeDescription
$labelstring
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetMultiOptions(array $options) : \Zend_Form_Element_Multi
inherited

Set all options at once (overwrites)

Inherited from: \Zend_Form_Element_Multi::setMultiOptions()\Zend_Form_Element_Select::setMultiOptions()
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Form_Element_Multi
methodpublicsetName(string $name) : \Zend_Form_Element
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetOptions(array $options) : \Zend_Form_Element
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetOrder(int $order) : \Zend_Form_Element
Parameters
NameTypeDescription
$orderint
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_Form_Element
Parameters
NameTypeDescription
$loader\Zend_Loader_PluginLoader_Interface
$typestring

'decorator', 'filter', or 'validate'

Returns
TypeDescription
\Zend_Form_Element
Throws
ExceptionDescription
\Zend_Form_Exceptionon invalid type
methodpublicsetRegisterInArrayValidator(bool $flag) : \Zend_Form_Element_Multi
inherited

Set flag indicating whether or not to auto-register inArray validator

Inherited from: \Zend_Form_Element_Multi::setRegisterInArrayValidator()\Zend_Form_Element_Select::setRegisterInArrayValidator()
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Form_Element_Multi
methodpublicsetRequired(bool $flag = true) : \Zend_Form_Element
Parameters
NameTypeDescription
$flagbool

Default value is true

Returns
TypeDescription
\Zend_Form_Element
methodpublicsetSeparator(mixed $separator) : \Zend_Form_Element_Multiselect
Parameters
NameTypeDescription
$separatormixed
Returns
TypeDescription
\Zend_Form_Element_Multiselect
Details
Fluent
This method is part of a fluent interface and will return the same instance  
methodpublicsetTranslator(\Zend_Translate | null $translator = null) : \Zend_Form_Element
Parameters
NameTypeDescription
$translator\Zend_Translate | null
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetValidators(array $validators) : \Zend_Form_Element
Parameters
NameTypeDescription
$validatorsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetValue(mixed $value) : \Zend_Form_Element
Parameters
NameTypeDescription
$valuemixed
Returns
TypeDescription
\Zend_Form_Element
Documentation was generated by phpDocumentor 2.0.0a12.