Form/Decorator/ViewHelper.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
\Zend_Form_Decorator_ViewHelper
Zend_Form_Decorator_ViewHelper
Decorate an element by using a view helper to render it.
Accepts the following options: - separator: string with which to separate passed in content and generated content - placement: whether to append or prepend the generated content to the passed in content - helper: the name of the view helper to use
Assumes the view helper accepts three parameters, the name, value, and optional attributes; these will be provided by the element.
- Parent(s)
- \Zend_Form_Decorator_Abstract
- Children
- \Zend_Dojo_Form_Decorator_DijitElement
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Version
- $Id: ViewHelper.php 25189 2013-01-08 08:32:43Z frosch $
Constants

PREPEND
= 'PREPEND'
- Inherited_from
- \Zend_Form_Decorator_Abstract::PREPEND
Properties


array $_buttonTypes = array('Zend_Form_Element_Button', 'Zend_Form_Element_Reset', 'Zend_Form_Element_Submit')
Element types that represent buttons
array('Zend_Form_Element_Button', 'Zend_Form_Element_Reset', 'Zend_Form_Element_Submit')
Details- Type
- array


\Zend_Form_Element|\Zend_Form $_element =
- Type
- \Zend_Form_Element | \Zend_Form
- Inherited_from
- \Zend_Form_Decorator_Abstract::$$_element


array $_options = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Form_Decorator_Abstract::$$_options


string $_placement = 'APPEND'
'APPEND'
Details- Type
- string
- Inherited_from
- \Zend_Form_Decorator_Abstract::$$_placement


string $_separator = PHP_EOL
Separator between new content and old
Inherited from: \Zend_Form_Decorator_Abstract::$$_separatorPHP_EOL
Details- Type
- string
- Inherited_from
- \Zend_Form_Decorator_Abstract::$$_separator
Methods


__construct(array | \Zend_Config $options = null) : void
Accept options during initialization.
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config |


clearOptions() : \Zend_Form_Decorator_Abstract
Type | Description |
---|---|
\Zend_Form_Decorator_Abstract |


getElement() : \Zend_Form_Element | \Zend_Form
Type | Description |
---|---|
\Zend_Form_Element | \Zend_Form |


getElementAttribs() : array
Retrieve element attributes
Set id to element name and/or array item.
Type | Description |
---|---|
array |


getName() : string
Get name
If element is a Zend_Form_Element, will attempt to namespace it if the element belongs to an array.
Type | Description |
---|---|
string |


getOption(string $key) : mixed
Name | Type | Description |
---|---|---|
$key | string |
Type | Description |
---|---|
mixed |


getPlacement() : string
Determine if decorator should append or prepend content
Inherited from: \Zend_Form_Decorator_Abstract::getPlacement()Type | Description |
---|---|
string |


getSeparator() : string
Retrieve separator to use between old and new content
Inherited from: \Zend_Form_Decorator_Abstract::getSeparator()Type | Description |
---|---|
string |


getValue(\Zend_Form_Element $element) : string | null
Get value
If element type is one of the button types, returns the label.
Name | Type | Description |
---|---|---|
$element | \Zend_Form_Element |
Type | Description |
---|---|
string | null |


render(string $content) : string
Render an element using a view helper
Determine view helper from 'viewHelper' option, or, if none set, from the element type. Then call as helper($element->getName(), $element->getValue(), $element->getAttribs())
Name | Type | Description |
---|---|---|
$content | string |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Form_Decorator_Exception | if element or view are not registered |


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


setElement(\Zend_Form_Element | \Zend_Form $element) : \Zend_Form_Decorator_Abstract
While the name is "setElement", a form decorator could decorate either an element or a form object.
Name | Type | Description |
---|---|---|
$element | \Zend_Form_Element | \Zend_Form |
Type | Description |
---|---|
\Zend_Form_Decorator_Abstract |
Exception | Description |
---|---|
\Zend_Form_Decorator_Exception | on invalid element type |


setHelper(string $helper) : \Zend_Form_Decorator_Element_ViewHelper
Set view helper to use when rendering
Name | Type | Description |
---|---|---|
$helper | string |
Type | Description |
---|---|
\Zend_Form_Decorator_Element_ViewHelper |


setOption(string $key, mixed $value) : \Zend_Form_Decorator_Abstract
Name | Type | Description |
---|---|---|
$key | string | |
$value | mixed |
Type | Description |
---|---|
\Zend_Form_Decorator_Abstract |


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