import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -32,7 +32,7 @@ require_once 'Zend/Validate/Interface.php';
|
||||
* @subpackage Element
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Element.php 17506 2009-08-10 11:30:24Z yoshida@zend.co.jp $
|
||||
* @version $Id: Element.php 19130 2009-11-20 19:28:00Z matthew $
|
||||
*/
|
||||
class Zend_Form_Element implements Zend_Validate_Interface
|
||||
{
|
||||
@ -97,6 +97,13 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
*/
|
||||
protected $_errors = array();
|
||||
|
||||
/**
|
||||
* Separator to use when concatenating aggregate error messages (for
|
||||
* elements having array values)
|
||||
* @var string
|
||||
*/
|
||||
protected $_errorMessageSeparator = '; ';
|
||||
|
||||
/**
|
||||
* Element filters
|
||||
* @var array
|
||||
@ -121,6 +128,12 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
*/
|
||||
protected $_isError = false;
|
||||
|
||||
/**
|
||||
* Has the element been manually marked as invalid?
|
||||
* @var bool
|
||||
*/
|
||||
protected $_isErrorForced = false;
|
||||
|
||||
/**
|
||||
* Element label
|
||||
* @var string
|
||||
@ -197,6 +210,16 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
*/
|
||||
protected $_view;
|
||||
|
||||
/**
|
||||
* Is a specific decorator being rendered via the magic renderDecorator()?
|
||||
*
|
||||
* This is to allow execution of logic inside the render() methods of child
|
||||
* elements during the magic call while skipping the parent render() method.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_isPartialRendering = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -900,6 +923,9 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if ('render' == substr($method, 0, 6)) {
|
||||
$this->_isPartialRendering = true;
|
||||
$this->render();
|
||||
$this->_isPartialRendering = false;
|
||||
$decoratorName = substr($method, 6);
|
||||
if (false !== ($decorator = $this->getDecorator($decoratorName))) {
|
||||
$decorator->setElement($this);
|
||||
@ -1339,6 +1365,11 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
}
|
||||
}
|
||||
|
||||
// If element manually flagged as invalid, return false
|
||||
if ($this->_isErrorForced) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1401,6 +1432,28 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get errorMessageSeparator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorMessageSeparator()
|
||||
{
|
||||
return $this->_errorMessageSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set errorMessageSeparator
|
||||
*
|
||||
* @param string $separator
|
||||
* @return Zend_Form_Element
|
||||
*/
|
||||
public function setErrorMessageSeparator($separator)
|
||||
{
|
||||
$this->_errorMessageSeparator = $separator;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the element as being in a failed validation state
|
||||
*
|
||||
@ -1416,6 +1469,7 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
} else {
|
||||
$this->_messages = $messages;
|
||||
}
|
||||
$this->_isErrorForced = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -1903,6 +1957,10 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
*/
|
||||
public function render(Zend_View_Interface $view = null)
|
||||
{
|
||||
if ($this->_isPartialRendering) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (null !== $view) {
|
||||
$this->setView($view);
|
||||
}
|
||||
@ -2099,12 +2157,14 @@ class Zend_Form_Element implements Zend_Validate_Interface
|
||||
if (null !== $translator) {
|
||||
$message = $translator->translate($message);
|
||||
}
|
||||
if ($this->isArray() || is_array($value)) {
|
||||
if (($this->isArray() || is_array($value))
|
||||
&& !empty($value)
|
||||
) {
|
||||
$aggregateMessages = array();
|
||||
foreach ($value as $val) {
|
||||
$aggregateMessages[] = str_replace('%value%', $val, $message);
|
||||
}
|
||||
$messages[$key] = $aggregateMessages;
|
||||
$messages[$key] = implode($this->getErrorMessageSeparator(), $aggregateMessages);
|
||||
} else {
|
||||
$messages[$key] = str_replace('%value%', $value, $message);
|
||||
}
|
||||
|
Reference in New Issue
Block a user