import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -28,7 +28,7 @@ require_once 'Zend/Validate/Interface.php';
|
||||
* @package Zend_Form
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Form.php 11410 2008-09-15 02:21:42Z yoshida@zend.co.jp $
|
||||
* @version $Id: Form.php 16048 2009-06-13 09:15:09Z matthew $
|
||||
*/
|
||||
class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
{
|
||||
@ -97,6 +97,12 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
*/
|
||||
protected $_displayGroups = array();
|
||||
|
||||
/**
|
||||
* Global decorators to apply to all elements
|
||||
* @var null|array
|
||||
*/
|
||||
protected $_elementDecorators;
|
||||
|
||||
/**
|
||||
* Prefix paths to use when creating elements
|
||||
* @var array
|
||||
@ -306,16 +312,16 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
unset($options['displayGroupPrefixPath']);
|
||||
}
|
||||
|
||||
if (isset($options['elementDecorators'])) {
|
||||
$this->_elementDecorators = $options['elementDecorators'];
|
||||
unset($options['elementDecorators']);
|
||||
}
|
||||
|
||||
if (isset($options['elements'])) {
|
||||
$this->setElements($options['elements']);
|
||||
unset($options['elements']);
|
||||
}
|
||||
|
||||
if (isset($options['elementDecorators'])) {
|
||||
$elementDecorators = $options['elementDecorators'];
|
||||
unset($options['elementDecorators']);
|
||||
}
|
||||
|
||||
if (isset($options['defaultDisplayGroupClass'])) {
|
||||
$this->setDefaultDisplayGroupClass($options['defaultDisplayGroupClass']);
|
||||
unset($options['defaultDisplayGroupClass']);
|
||||
@ -355,10 +361,6 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($elementDecorators)) {
|
||||
$this->setElementDecorators($elementDecorators);
|
||||
}
|
||||
|
||||
if (isset($displayGroupDecorators)) {
|
||||
$this->setDisplayGroupDecorators($displayGroupDecorators);
|
||||
}
|
||||
@ -983,6 +985,19 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
throw new Zend_Form_Exception('Elements specified by string must have an accompanying name');
|
||||
}
|
||||
|
||||
if (is_array($this->_elementDecorators)) {
|
||||
if (null === $options) {
|
||||
$options = array('decorators' => $this->_elementDecorators);
|
||||
} elseif ($options instanceof Zend_Config) {
|
||||
$options = $options->toArray();
|
||||
}
|
||||
if (is_array($options)
|
||||
&& !array_key_exists('decorators', $options)
|
||||
) {
|
||||
$options['decorators'] = $this->_elementDecorators;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_elements[$name] = $this->createElement($element, $name, $options);
|
||||
} elseif ($element instanceof Zend_Form_Element) {
|
||||
$prefixPaths = array();
|
||||
@ -1784,7 +1799,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
* Return a display group
|
||||
*
|
||||
* @param string $name
|
||||
* @return array|null
|
||||
* @return Zend_Form_DisplayGroup|null
|
||||
*/
|
||||
public function getDisplayGroup($name)
|
||||
{
|
||||
@ -2322,8 +2337,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
if (null === $options) {
|
||||
$decorator = new $class;
|
||||
} else {
|
||||
$r = new ReflectionClass($class);
|
||||
$decorator = $r->newInstance($options);
|
||||
$decorator = new $class($options);
|
||||
}
|
||||
|
||||
return $decorator;
|
||||
@ -2545,6 +2559,8 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
|
||||
$element->setDecorators($decorators);
|
||||
}
|
||||
|
||||
$this->_elementDecorators = $decorators;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user