Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store


Zend_Form_Element's constructor accepts either an array of options or a Zend_Config object containing options, and it can also be configured using either setOptions() or setConfig(). Generally speaking, keys are named as follows:

  • If 'set' + key refers to a Zend_Form_Element method, then the value provided will be passed to that method.

  • Otherwise, the value will be used to set an attribute.

Exceptions to the rule include the following:

  • prefixPath will be passed to addPrefixPaths()

  • The following setters cannot be set in this way:

    • setAttrib (though setAttribs will work)

    • setConfig

    • setOptions

    • setPluginLoader

    • setTranslator

    • setView

As an example, here is a config file that passes configuration for every type of configurable data:

name = "foo"
value = "foobar"
label = "Foo:"
order = 10
required = true
allowEmpty = false
autoInsertNotEmptyValidator = true
description = "Foo elements are for examples"
ignore = false = "foo"
attribs.class = "element"
; For radio button elements
escape = true
listsep = "<br />\n"
; sets 'onclick' attribute
onclick = "autoComplete(this, '/form/autocomplete/element')"
prefixPaths.decorator.prefix = "My_Decorator"
prefixPaths.decorator.path = "My/Decorator/"
disableTranslator = 0
validators.required.validator = "NotEmpty"
validators.required.breakChainOnFailure = true
validators.alpha.validator = "alpha"
validators.regex.validator = "regex"
validators.regex.options.pattern = "/^[A-F].*/$"
filters.ucase.filter = "StringToUpper"
decorators.element.decorator = "ViewHelper"
decorators.element.options.helper = "FormText"
decorators.label.decorator = "Label"

Zend Framework