--- a/web/lib/Zend/Form/Element.php Thu Mar 21 17:31:31 2013 +0100
+++ b/web/lib/Zend/Form/Element.php Thu Mar 21 19:50:53 2013 +0100
@@ -14,7 +14,7 @@
*
* @category Zend
* @package Zend_Form
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@@ -36,9 +36,9 @@
* @category Zend
* @package Zend_Form
* @subpackage Element
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Element.php 22464 2010-06-19 17:31:21Z alab $
+ * @version $Id: Element.php 25173 2012-12-22 20:05:32Z rob $
*/
class Zend_Form_Element implements Zend_Validate_Interface
{
@@ -315,20 +315,32 @@
$decorators = $this->getDecorators();
if (empty($decorators)) {
- $getId = create_function('$decorator',
- 'return $decorator->getElement()->getId()
- . "-element";');
$this->addDecorator('ViewHelper')
->addDecorator('Errors')
->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
- ->addDecorator('HtmlTag', array('tag' => 'dd',
- 'id' => array('callback' => $getId)))
+ ->addDecorator('HtmlTag', array(
+ 'tag' => 'dd',
+ 'id' => array('callback' => array(get_class($this), 'resolveElementId'))
+ ))
->addDecorator('Label', array('tag' => 'dt'));
}
return $this;
}
/**
+ * Used to resolve and return an element ID
+ *
+ * Passed to the HtmlTag decorator as a callback in order to provide an ID.
+ *
+ * @param Zend_Form_Decorator_Interface $decorator
+ * @return string
+ */
+ public static function resolveElementId(Zend_Form_Decorator_Interface $decorator)
+ {
+ return $decorator->getElement()->getId() . '-element';
+ }
+
+ /**
* Set object state from options array
*
* @param array $options
@@ -892,6 +904,7 @@
public function getAttribs()
{
$attribs = get_object_vars($this);
+ unset($attribs['helper']);
foreach ($attribs as $key => $value) {
if ('_' == substr($key, 0, 1)) {
unset($attribs[$key]);
@@ -1058,14 +1071,13 @@
$loader->addPrefixPath($prefix, $path);
return $this;
case null:
- $prefix = rtrim($prefix, '_');
- $path = rtrim($path, DIRECTORY_SEPARATOR);
+ $nsSeparator = (false !== strpos($prefix, '\\'))?'\\':'_';
+ $prefix = rtrim($prefix, $nsSeparator) . $nsSeparator;
+ $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
foreach (array(self::DECORATOR, self::FILTER, self::VALIDATE) as $type) {
$cType = ucfirst(strtolower($type));
- $pluginPath = $path . DIRECTORY_SEPARATOR . $cType . DIRECTORY_SEPARATOR;
- $pluginPrefix = $prefix . '_' . $cType;
$loader = $this->getPluginLoader($type);
- $loader->addPrefixPath($pluginPrefix, $pluginPath);
+ $loader->addPrefixPath($prefix . $cType, $path . $cType . DIRECTORY_SEPARATOR);
}
return $this;
default:
@@ -1377,7 +1389,14 @@
if ($isArray && is_array($value)) {
$messages = array();
$errors = array();
- foreach ($value as $val) {
+ if (empty($value)) {
+ if ($this->isRequired()
+ || (!$this->isRequired() && !$this->getAllowEmpty())
+ ) {
+ $value = '';
+ }
+ }
+ foreach ((array)$value as $val) {
if (!$validator->isValid($val, $context)) {
$result = false;
if ($this->_hasErrorMessages()) {
@@ -2223,14 +2242,14 @@
if (null !== $translator) {
$message = $translator->translate($message);
}
- if (($this->isArray() || is_array($value))
- && !empty($value)
- ) {
+ if ($this->isArray() || is_array($value)) {
$aggregateMessages = array();
foreach ($value as $val) {
$aggregateMessages[] = str_replace('%value%', $val, $message);
}
- $messages[$key] = implode($this->getErrorMessageSeparator(), $aggregateMessages);
+ if (count($aggregateMessages)) {
+ $messages[$key] = implode($this->getErrorMessageSeparator(), $aggregateMessages);
+ }
} else {
$messages[$key] = str_replace('%value%', $value, $message);
}