Bläddra i källkod

[Form] Fix the FormView::isRendered() method

Victor Berchet 14 år sedan
förälder
incheckning
eed54c137e
1 ändrade filer med 15 tillägg och 5 borttagningar
  1. 15 5
      src/Symfony/Component/Form/FormView.php

+ 15 - 5
src/Symfony/Component/Form/FormView.php

@@ -112,7 +112,21 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
      */
     public function isRendered()
     {
-        return $this->rendered;
+        if (true === $this->rendered || 0 == count($this->children)) {
+            return $this->rendered;
+        }
+
+        if (count($this->children) > 0) {
+            foreach ($this->children as $child) {
+                if (!$child->isRendered()) {
+                    return false;
+                }
+            }
+
+            return $this->rendered = true;
+        } else {
+            return false;
+        }
     }
 
     /**
@@ -258,10 +272,6 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
      */
     public function getIterator()
     {
-        if (count($this->children)) {
-            $this->rendered = true;
-        }
-
         return new \ArrayIterator($this->children);
     }