Checkbox form element

category Zend
package Zend_Form
subpackage Element
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
version $Id$
inherited_from \Zend_Form_Element_Xhtml

 Methods

Overloading: allow rendering specific decorators

__call(string $method, array $args) : string
Inherited

Call renderDecoratorName() to render a specific decorator.

Parameters

$method

string

$args

array

Exceptions

\Zend_Form_Exception for invalid decorator or invalid method call

Returns

string

Constructor

__construct(string|array|\Zend_Config $spec, array|\Zend_Config $options = null) : void
Inherited

$spec may be:

  • string: name of element
  • array: options with which to configure element
  • Zend_Config: Zend_Config with options for configuring element

Parameters

$spec

stringarray\Zend_Config

$options

array\Zend_Config

Exceptions

\Zend_Form_Exception if no element name after initialization

Overloading: retrieve object property

__get(string $key) : mixed
Inherited

Prevents access to properties beginning with '_'.

Parameters

$key

string

Returns

mixed

Overloading: set object property

__set(string $key, mixed $value) : \voide
Inherited

Parameters

$key

string

$value

mixed

Returns

\voide

String representation of form element

__toString() : string
Inherited

Proxies to \render().

Returns

string

Add a decorator for rendering the element

addDecorator(string|\Zend_Form_Decorator_Interface $decorator, array|\Zend_Config $options = null) : \Zend_Form_Element
Inherited

Parameters

$decorator

string\Zend_Form_Decorator_Interface

$options

array\Zend_Config

Options with which to initialize decorator

Returns

\Zend_Form_Element

Add many decorators at once

addDecorators(array $decorators) : \Zend_Form_Element
Inherited

Parameters

$decorators

array

Returns

\Zend_Form_Element

Add an error message and mark element as failed validation

addError(string $message) : \Zend_Form_Element
Inherited

Parameters

$message

string

Returns

\Zend_Form_Element

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

addErrorMessage(string $message) : \Zend_Form_Element
Inherited

Parameters

$message

string

Returns

\Zend_Form_Element

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

addErrorMessages(array $messages) : \Zend_Form_Element
Inherited

Parameters

$messages

array

Returns

\Zend_Form_Element

Add multiple error messages and flag element as failed validation

addErrors(array $messages) : \Zend_Form_Element
Inherited

Parameters

$messages

array

Returns

\Zend_Form_Element

Add a filter to the element

addFilter(string|\Zend_Filter_Interface $filter, $options = array()) : \Zend_Form_Element
Inherited

Parameters

$filter

string\Zend_Filter_Interface

$options

Returns

\Zend_Form_Element

Add filters to element

addFilters(array $filters) : \Zend_Form_Element
Inherited

Parameters

$filters

array

Returns

\Zend_Form_Element

Add prefix path for plugin loader

addPrefixPath(string $prefix, string $path, string $type = null) : \Zend_Form_Element
Inherited

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

$prefix

string

$path

string

$type

string

Exceptions

\Zend_Form_Exception for invalid type

Returns

\Zend_Form_Element

Add many prefix paths at once

addPrefixPaths(array $spec) : \Zend_Form_Element
Inherited

Parameters

$spec

array

Returns

\Zend_Form_Element

Add validator to validation chain

addValidator(string|\Zend_Validate_Interface $validator, boolean $breakChainOnFailure = false, array $options = array()) : \Zend_Form_Element
Inherited

Note: will overwrite existing validators if they are of the same class.

Parameters

$validator

string\Zend_Validate_Interface

$breakChainOnFailure

boolean

$options

array

Exceptions

\Zend_Form_Exception if invalid validator type

Returns

\Zend_Form_Element

Add multiple validators

addValidators(array $validators) : \Zend_Form_Element
Inherited

Parameters

$validators

array

Returns

\Zend_Form_Element

Get flag indicating whether a NotEmpty validator should be inserted when element is required

autoInsertNotEmptyValidator() : boolean
Inherited

Returns

boolean

Clear all decorators

clearDecorators() : \Zend_Form_Element
Inherited

Returns

\Zend_Form_Element

Clear custom error messages stack

clearErrorMessages() : \Zend_Form_Element
Inherited

Returns

\Zend_Form_Element

Clear all filters

clearFilters() : \Zend_Form_Element
Inherited

Returns

\Zend_Form_Element

Clear all validators

clearValidators() : \Zend_Form_Element
Inherited

Returns

\Zend_Form_Element

Filter a name to only allow valid variable characters

filterName(string $value, boolean $allowBrackets = false) : string
Inherited

Parameters

$value

string

$allowBrackets

boolean

Returns

string

Get 'allow empty' flag

getAllowEmpty() : boolean
Inherited

Returns

boolean

Retrieve element attribute

getAttrib(string $name) : string
Inherited

Parameters

$name

string

Returns

string

Return all attributes

getAttribs() : array
Inherited

Returns

array

Return array name to which element belongs

getBelongsTo() : string
Inherited

Returns

string

Get value when checked

getCheckedValue() : string

Returns

string

Use one error message for array elements with concatenated values

getConcatJustValuesInErrorMessage() : boolean
Inherited

Returns

boolean

Retrieve a registered decorator

getDecorator(string $name) : false | \Zend_Form_Decorator_Abstract
Inherited

Parameters

$name

string

Returns

false\Zend_Form_Decorator_Abstract

Retrieve all decorators

getDecorators() : array
Inherited

Returns

array

Retrieve element description

getDescription() : string
Inherited

Returns

string

Get errorMessageSeparator

getErrorMessageSeparator() : string
Inherited

Returns

string

Retrieve custom error messages

getErrorMessages() : array
Inherited

Returns

array

Retrieve validator chain errors

getErrors() : array
Inherited

Returns

array

Retrieve a single filter by name

getFilter(string $name) : \Zend_Filter_Interface
Inherited

Parameters

$name

string

Returns

\Zend_Filter_Interface

Get all filters

getFilters() : array
Inherited

Returns

array

Get fully qualified name

getFullyQualifiedName() : string
Inherited

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

Returns

string

Get element id

getId() : string
Inherited

Returns

string

Get ignore flag (used when retrieving values at form level)

getIgnore() : boolean
Inherited

Returns

boolean

Retrieve element label

getLabel() : string
Inherited

Returns

string

Retrieve error messages

getMessages() : array
Inherited

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

inherited_from \Zend_Validate_Interface::getMessages()

Returns

array

Return element name

getName() : string
Inherited

Returns

string

Retrieve element order

getOrder() : integer
Inherited

Returns

integer

Retrieve plugin loader for validator or filter chain

getPluginLoader(string $type) : \Zend_Loader_PluginLoader
Inherited

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

Parameters

$type

string

Exceptions

\Zend_Loader_Exception on invalid type.

Returns

\Zend_Loader_PluginLoader

Retrieve localization translator object

getTranslator() : \Zend_Translate_Adapter | null
Inherited

Returns

\Zend_Translate_Adapternull

Return element type

getType() : string
Inherited

Returns

string

Get value when not checked

getUncheckedValue() : string

Returns

string

Retrieve unfiltered element value

getUnfilteredValue() : mixed
Inherited

Returns

mixed

Retrieve a single validator by name

getValidator(string $name) : \Zend_Validate_Interface | false
Inherited

Parameters

$name

string

Returns

\Zend_Validate_InterfacefalseFalse if not found, validator otherwise

Retrieve all validators

getValidators() : array
Inherited

Returns

array

Retrieve filtered element value

getValue() : mixed
Inherited

Returns

mixed

Retrieve view object

getView() : null | \Zend_View_Interface
Inherited

Retrieves from ViewRenderer if none previously set.

Returns

null\Zend_View_Interface

Are there errors registered?

hasErrors() : boolean
Inherited

Returns

boolean

Does this element have its own specific translator?

hasTranslator() : boolean
Inherited

Returns

boolean

Initialize object; used by extending classes

init() : void
Inherited

Is the element representing an array?

isArray() : boolean
Inherited

Returns

boolean

Get checked flag

isChecked() : boolean

Returns

boolean

Is the element required?

isRequired() : boolean
Inherited

Returns

boolean

Validate element value

isValid(mixed $value, mixed $context = null) : boolean
Inherited

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.

inherited_from \Zend_Validate_Interface::isValid()

Parameters

$value

mixed

$context

mixed

Returns

boolean

Load default decorators

loadDefaultDecorators() : \Zend_Form_Element
Inherited

Returns

\Zend_Form_Element

Should we load the default decorators?

loadDefaultDecoratorsIsDisabled() : boolean
Inherited

Returns

boolean

Mark the element as being in a failed validation state

markAsError() : \Zend_Form_Element
Inherited

Returns

\Zend_Form_Element

Remove a single decorator

removeDecorator(string $name) : \Zend_Form_Element
Inherited

Parameters

$name

string

Returns

\Zend_Form_Element

Remove a filter by name

removeFilter(string $name) : \Zend_Form_Element
Inherited

Parameters

$name

string

Returns

\Zend_Form_Element

Remove a single validator by name

removeValidator(string $name) : boolean
Inherited

Parameters

$name

string

Returns

boolean

Render form element

render(\Zend_View_Interface $view = null) : string
Inherited

Parameters

$view

\Zend_View_Interface

Returns

string

Used to resolve and return an element ID

resolveElementId(\Zend_Form_Decorator_Interface $decorator) : string
InheritedStatic

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

Parameters

$decorator

\Zend_Form_Decorator_Interface

Returns

string

Set 'allow empty' flag

setAllowEmpty(boolean $flag) : \Zend_Form_Element
Inherited

When the allow empty flag is enabled and the required flag is false, the element will validate with empty values.

Parameters

$flag

boolean

Returns

\Zend_Form_Element

Set element attribute

setAttrib(string $name, mixed $value) : \Zend_Form_Element
Inherited

Parameters

$name

string

$value

mixed

Exceptions

\Zend_Form_Exception for invalid $name values

Returns

\Zend_Form_Element

Set multiple attributes at once

setAttribs(array $attribs) : \Zend_Form_Element
Inherited

Parameters

$attribs

array

Returns

\Zend_Form_Element

Set flag indicating whether a NotEmpty validator should be inserted when element is required

setAutoInsertNotEmptyValidator(boolean $flag) : \Zend_Form_Element
Inherited

Parameters

$flag

boolean

Returns

\Zend_Form_Element

Set array to which element belongs

setBelongsTo(string $array) : \Zend_Form_Element
Inherited

Parameters

$array

string

Returns

\Zend_Form_Element

Set checked flag

setChecked(boolean $flag) : \Zend_Form_Element_Checkbox

Parameters

$flag

boolean

Returns

\Zend_Form_Element_Checkbox

Set checked value

setCheckedValue(string $value) : \Zend_Form_Element_Checkbox

Parameters

$value

string

Returns

\Zend_Form_Element_Checkbox

Use one error message for array elements with concatenated values

setConcatJustValuesInErrorMessage(boolean $concatJustValuesInErrorMessage) : \Zend_Form_Element
Inherited

Parameters

$concatJustValuesInErrorMessage

boolean

Returns

\Zend_Form_Element

Set object state from Zend_Config object

setConfig(\Zend_Config $config) : \Zend_Form_Element
Inherited

Parameters

$config

\Zend_Config

Returns

\Zend_Form_Element

Overwrite all decorators

setDecorators(array $decorators) : \Zend_Form_Element
Inherited

Parameters

$decorators

array

Returns

\Zend_Form_Element

Set element description

setDescription(string $description) : \Zend_Form_Element
Inherited

Parameters

$description

string

Returns

\Zend_Form_Element

Set flag to disable loading default decorators

setDisableLoadDefaultDecorators(boolean $flag) : \Zend_Form_Element
Inherited

Parameters

$flag

boolean

Returns

\Zend_Form_Element

Indicate whether or not translation should be disabled

setDisableTranslator(boolean $flag) : \Zend_Form_Element
Inherited

Parameters

$flag

boolean

Returns

\Zend_Form_Element

Set errorMessageSeparator

setErrorMessageSeparator(string $separator) : \Zend_Form_Element
Inherited

Parameters

$separator

string

Returns

\Zend_Form_Element

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

setErrorMessages(array $messages) : \Zend_Form_Element
Inherited

Parameters

$messages

array

Returns

\Zend_Form_Element

Overwrite any previously set error messages and flag as failed validation

setErrors(array $messages) : \Zend_Form_Element
Inherited

Parameters

$messages

array

Returns

\Zend_Form_Element

Add filters to element, overwriting any already existing

setFilters(array $filters) : \Zend_Form_Element
Inherited

Parameters

$filters

array

Returns

\Zend_Form_Element

Set ignore flag (used when retrieving values at form level)

setIgnore(boolean $flag) : \Zend_Form_Element
Inherited

Parameters

$flag

boolean

Returns

\Zend_Form_Element

Set flag indicating if element represents an array

setIsArray(boolean $flag) : \Zend_Form_Element
Inherited

Parameters

$flag

boolean

Returns

\Zend_Form_Element

Set element label

setLabel(string $label) : \Zend_Form_Element
Inherited

Parameters

$label

string

Returns

\Zend_Form_Element

Set element name

setName(string $name) : \Zend_Form_Element
Inherited

Parameters

$name

string

Returns

\Zend_Form_Element

Set options

setOptions(array $options) : \Zend_Form_Element_Checkbox

Intercept checked and unchecked values and set them early; test stored value against checked and unchecked values after configuration.

Parameters

$options

array

Returns

\Zend_Form_Element_Checkbox

Set object state from options array

setOptions(array $options) : \Zend_Form_Element
Inherited

Parameters

$options

array

Returns

\Zend_Form_Element

Set element order

setOrder(integer $order) : \Zend_Form_Element
Inherited

Parameters

$order

integer

Returns

\Zend_Form_Element

Set plugin loader to use for validator or filter chain

setPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_Form_Element
Inherited

Parameters

$loader

\Zend_Loader_PluginLoader_Interface

$type

string

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

Exceptions

\Zend_Form_Exception on invalid type

Returns

\Zend_Form_Element

Set required flag

setRequired(boolean $flag = true) : \Zend_Form_Element
Inherited

Parameters

$flag

boolean

Default value is true

Returns

\Zend_Form_Element

Set translator object for localization

setTranslator(\Zend_Translate|null $translator = null) : \Zend_Form_Element
Inherited

Parameters

$translator

\Zend_Translatenull

Returns

\Zend_Form_Element

Set unchecked value

setUncheckedValue(string $value) : \Zend_Form_Element_Checkbox

Parameters

$value

string

Returns

\Zend_Form_Element_Checkbox

Set multiple validators, overwriting previous validators

setValidators(array $validators) : \Zend_Form_Element
Inherited

Parameters

$validators

array

Returns

\Zend_Form_Element

Set value

setValue(mixed $value) : \Zend_Form_Element_Checkbox

If value matches checked value, sets to that value, and sets the checked flag to true.

Any other value causes the unchecked value to be set as the current value, and the checked flag to be set as false.

Parameters

$value

mixed

Returns

\Zend_Form_Element_Checkbox

Set element value

setValue(mixed $value) : \Zend_Form_Element
Inherited

Parameters

$value

mixed

Returns

\Zend_Form_Element

Set view object

setView(\Zend_View_Interface $view = null) : \Zend_Form_Element
Inherited

Parameters

$view

\Zend_View_Interface

Returns

\Zend_Form_Element

Is translation disabled?

translatorIsDisabled() : boolean
Inherited

Returns

boolean

Filter a value

_filterValue(string $value, string $key) : void
Inherited

Parameters

$value

string

$key

string

Instantiate a decorator based on class name or class name fragment

_getDecorator(string $name, null|array $options) : \Zend_Form_Decorator_Interface
Inherited

Parameters

$name

string

$options

nullarray

Returns

\Zend_Form_Decorator_Interface

Retrieve error messages and perform translation and value substitution

_getErrorMessages() : array
Inherited

Returns

array

Are there custom error messages registered?

_hasErrorMessages() : boolean
Inherited

Returns

boolean

Lazy-load a decorator

_loadDecorator(array $decorator, mixed $name) : \Zend_Form_Decorator_Interface
Inherited

Parameters

$decorator

array

Decorator type and options

$name

mixed

Decorator name or alias

Returns

\Zend_Form_Decorator_Interface

Lazy-load a filter

_loadFilter(array $filter) : \Zend_Filter_Interface
Inherited

Parameters

$filter

array

Returns

\Zend_Filter_Interface

Lazy-load a validator

_loadValidator(array $validator) : \Zend_Validate_Interface
Inherited

Parameters

$validator

array

Validator definition

Returns

\Zend_Validate_Interface

 Properties

 

Is the checkbox checked?

$checked : boolean

Default

false
 

Use formCheckbox view helper by default

$helper : string

Default

'formCheckbox'
 

Default view helper to use

$helper : string

Default

'formText'
 

Options that will be passed to the view helper

$options : array

Default

array('checkedValue' => '1', 'uncheckedValue' => '0')
 

'Allow empty' flag

$_allowEmpty : boolean

Default

true
 

Flag indicating whether or not to insert NotEmpty validator when element is required

$_autoInsertNotEmptyValidator : boolean

Default

true
 

Array to which element belongs

$_belongsTo : string

Default

 

Value when checked

$_checkedValue : string

Default

'1'
 

Use one error message for array elements with concatenated values

$_concatJustValuesInErrorMessage : boolean

Default

false
 

Element decorators

$_decorators : array

Default

array()
 

Element description

$_description : string

Default

 

Should we disable loading the default decorators?

$_disableLoadDefaultDecorators : boolean

Default

false
 

Separator to use when concatenating aggregate error messages (for elements having array values)

$_errorMessageSeparator : string

Default

'; '
 

Custom error messages

$_errorMessages : array

Default

array()
 

Validation errors

$_errors : array

Default

array()
 

Element filters

$_filters : array

Default

array()
 

Ignore flag (used when retrieving values at form level)

$_ignore : boolean

Default

false
 

Does the element represent an array?

$_isArray : boolean

Default

false
 

Is the error marked as in an invalid state?

$_isError : boolean

Default

false
 

Has the element been manually marked as invalid?

$_isErrorForced : boolean

Default

false
 

Is a specific decorator being rendered via the magic renderDecorator()?

$_isPartialRendering : boolean

Default

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.

 

Element label

$_label : string

Default

 

Plugin loaders for filter and validator chains

$_loaders : array

Default

array()
 

Formatted validation error messages

$_messages : array

Default

array()
 

Element name

$_name : string

Default

 

Order of element

$_order : integer

Default

 

Required flag

$_required : boolean

Default

false
 

$_translator

$_translator : \Zend_Translate

Default

 

Is translation disabled?

$_translatorDisabled : boolean

Default

false
 

Element type

$_type : string

Default

 

Value when not checked

$_uncheckedValue : string

Default

'0'
 

Array of un-initialized validators

$_validatorRules : array

Default

array()
 

Array of initialized validators

$_validators : array

Default

array()
 

Current value

$_value : string

Default

'0'
 

Element value

$_value : mixed

Default

 

$_view

$_view : \Zend_View_Interface

Default

 Constants

 

Element Constants

DECORATOR = 'DECORATOR' 
 

FILTER

FILTER = 'FILTER' 
 

VALIDATE

VALIDATE = 'VALIDATE'