|
|
@@ -44,6 +44,8 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
|
|
|
*/
|
|
|
protected $_defaults = array(
|
|
|
'ignoreSubForms' => false,
|
|
|
+ 'showCustomFormErrors' => true,
|
|
|
+ 'onlyCustomFormErrors' => false,
|
|
|
'markupElementLabelEnd' => '</b>',
|
|
|
'markupElementLabelStart' => '<b>',
|
|
|
'markupListEnd' => '</ul>',
|
|
|
@@ -57,6 +59,8 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
|
|
|
* @var string
|
|
|
*/
|
|
|
protected $_ignoreSubForms;
|
|
|
+ protected $_showCustomFormErrors;
|
|
|
+ protected $_onlyCustomFormErrors;
|
|
|
protected $_markupElementLabelEnd;
|
|
|
protected $_markupElementLabelStart;
|
|
|
protected $_markupListEnd;
|
|
|
@@ -338,6 +342,65 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get showCustomFormErrors
|
|
|
+ *
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function getShowCustomFormErrors()
|
|
|
+ {
|
|
|
+ if (null === $this->_showCustomFormErrors) {
|
|
|
+ if (null === ($how = $this->getOption('showCustomFormErrors'))) {
|
|
|
+ $this->setShowCustomFormErrors($this->_defaults['showCustomFormErrors']);
|
|
|
+ } else {
|
|
|
+ $this->setShowCustomFormErrors($show);
|
|
|
+ $this->removeOption('showCustomFormErrors');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set showCustomFormErrors
|
|
|
+ *
|
|
|
+ * @param bool $showCustomFormErrors
|
|
|
+ * @return Zend_Form_Decorator_FormErrors
|
|
|
+ */
|
|
|
+ public function setShowCustomFormErrors($showCustomFormErrors)
|
|
|
+ {
|
|
|
+ $this->_showCustomFormErrors = (bool)$showCustomFormErrors;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get onlyCustomFormErrors
|
|
|
+ *
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function getOnlyCustomFormErrors()
|
|
|
+ {
|
|
|
+ if (null === $this->_onlyCustomFormErrors) {
|
|
|
+ if (null === ($how = $this->getOption('onlyCustomFormErrors'))) {
|
|
|
+ $this->setOnlyCustomFormErrors($this->_defaults['onlyCustomFormErrors']);
|
|
|
+ } else {
|
|
|
+ $this->setOnlyCustomFormErrors($show);
|
|
|
+ $this->removeOption('onlyCustomFormErrors');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set onlyCustomFormErrors, whether to display elements messages
|
|
|
+ * in addition to custom form messages.
|
|
|
+ *
|
|
|
+ * @param bool $onlyCustomFormErrors
|
|
|
+ * @return Zend_Form_Decorator_FormErrors
|
|
|
+ */
|
|
|
+ public function setOnlyCustomFormErrors($onlyCustomFormErrors)
|
|
|
+ {
|
|
|
+ $this->_onlyCustomFormErrors = (bool)$onlyCustomFormErrors;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Render element label
|
|
|
*
|
|
|
* @param Zend_Form_Element $element
|
|
|
@@ -367,8 +430,14 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
|
|
|
{
|
|
|
$content = '';
|
|
|
|
|
|
+ $custom = $form->getCustomMessages();
|
|
|
+ if ($this->getShowCustomFormErrors() && count($custom)) {
|
|
|
+ $content .= $this->getMarkupListItemStart()
|
|
|
+ . $view->formErrors($custom, $this->getOptions())
|
|
|
+ . $this->getMarkupListItemEnd();
|
|
|
+ }
|
|
|
foreach ($form->getElementsAndSubFormsOrdered() as $subitem) {
|
|
|
- if ($subitem instanceof Zend_Form_Element) {
|
|
|
+ if ($subitem instanceof Zend_Form_Element && !$this->getOnlyCustomFormErrors()) {
|
|
|
$messages = $subitem->getMessages();
|
|
|
if (count($messages)) {
|
|
|
$subitem->setView($view);
|
|
|
@@ -383,7 +452,6 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
|
|
|
. $this->getMarkupListEnd();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return $content;
|
|
|
}
|
|
|
}
|