فهرست منبع

ZF-5385: fix and UnitTests for r22272

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22316 44c647ce-9c0f-0410-b52a-842ac1e357ba
alab 15 سال پیش
والد
کامیت
8d97f8ec03
2فایلهای تغییر یافته به همراه23 افزوده شده و 2 حذف شده
  1. 6 2
      library/Zend/Form/Decorator/FormErrors.php
  2. 17 0
      tests/Zend/Form/Decorator/FormErrorsTest.php

+ 6 - 2
library/Zend/Form/Decorator/FormErrors.php

@@ -122,6 +122,8 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
         $this->getPlacement();
         $this->getSeparator();
         $this->ignoreSubForms();
+        $this->getShowCustomFormErrors();
+        $this->getOnlyCustomFormErrors();
     }
 
     /**
@@ -356,6 +358,7 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
                 $this->removeOption('showCustomFormErrors');
             }
         }
+        return $this->_showCustomFormErrors;
     }
 
     /**
@@ -378,13 +381,14 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
     public function getOnlyCustomFormErrors()
     {
         if (null === $this->_onlyCustomFormErrors) {
-            if (null === ($how =  $this->getOption('onlyCustomFormErrors'))) {
+            if (null === ($show =  $this->getOption('onlyCustomFormErrors'))) {
                 $this->setOnlyCustomFormErrors($this->_defaults['onlyCustomFormErrors']);
             } else {
                 $this->setOnlyCustomFormErrors($show);
                 $this->removeOption('onlyCustomFormErrors');
             }
         }
+        return $this->_onlyCustomFormErrors;
     }
 
     /**
@@ -446,7 +450,7 @@ class Zend_Form_Decorator_FormErrors extends Zend_Form_Decorator_Abstract
                              .  $view->formErrors($messages, $this->getOptions())
                              .  $this->getMarkupListItemEnd();
                 }
-            } else if (!$this->ignoreSubForms()) {
+            } else if ($subitem instanceof Zend_Form && !$this->ignoreSubForms()) {
                 $content .= $this->getMarkupListStart()
                           . $this->_recurseForm($subitem, $view)
                           . $this->getMarkupListEnd();

+ 17 - 0
tests/Zend/Form/Decorator/FormErrorsTest.php

@@ -274,6 +274,23 @@ class Zend_Form_Decorator_FormErrorsTest extends PHPUnit_Framework_TestCase
         }
     }
 
+    public function testCustomFormErrors()
+    {
+        $this->setupForm();
+        $this->form->addDecorator($this->decorator)
+                   ->addError('form-badness');
+        $html = $this->form->render();
+        $this->assertContains('form-badness', $html);
+
+        $this->decorator->setOnlyCustomFormErrors(true);
+        $html = $this->form->render();
+        $this->assertNotRegexp('/form-errors.*?Master Foo/', $html);
+
+        $this->decorator->setShowCustomFormErrors(false);
+        $html = $this->form->render();
+        $this->assertNotContains('form-badness', $html);
+    }
+
     /**
      * @dataProvider markupOptionMethodsProvider
      */