Просмотр исходного кода

ZF-9896: make getValidValues not collect values from ignored Elements

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22309 44c647ce-9c0f-0410-b52a-842ac1e357ba
alab 15 лет назад
Родитель
Сommit
f38f51870f
1 измененных файлов с 14 добавлено и 12 удалено
  1. 14 12
      library/Zend/Form.php

+ 14 - 12
library/Zend/Form.php

@@ -1396,20 +1396,22 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
         }
         $context = $data;
         foreach ($this->getElements() as $key => $element) {
-            $check = $data;
-            if (($belongsTo = $element->getBelongsTo()) !== $eBelongTo) {
-                $check = $this->_dissolveArrayValue($data, $belongsTo);
-            }
-            if (isset($check[$key])) {
-                if($element->isValid($check[$key], $context)) {
-                    $merge = array();
-                    if ($belongsTo !== $eBelongTo && '' !== (string)$belongsTo) {
-                        $key = $belongsTo . '[' . $key . ']';
+            if (!$element->getIgnore()) {
+                $check = $data;
+                if (($belongsTo = $element->getBelongsTo()) !== $eBelongTo) {
+                    $check = $this->_dissolveArrayValue($data, $belongsTo);
+                }
+                if (isset($check[$key])) {
+                    if($element->isValid($check[$key], $context)) {
+                        $merge = array();
+                        if ($belongsTo !== $eBelongTo && '' !== (string)$belongsTo) {
+                            $key = $belongsTo . '[' . $key . ']';
+                        }
+                        $merge = $this->_attachToArray($element->getValue(), $key);
+                        $values = $this->_array_replace_recursive($values, $merge);
                     }
-                    $merge = $this->_attachToArray($element->getValue(), $key);
-                    $values = $this->_array_replace_recursive($values, $merge);
+                    $data = $this->_dissolveArrayUnsetKey($data, $belongsTo, $key);
                 }
-                $data = $this->_dissolveArrayUnsetKey($data, $belongsTo, $key);
             }
         }
         foreach ($this->getSubForms() as $key => $form) {