_getDefaults(), $defaults); foreach ($this->getElements() as $name => $element) { $check = $defaults; if (array_key_exists($name, $check)) { $this->setDefault($name, $check[$name]); } } foreach ($this->getSubForms() as $name => $form) { // Give SubForm its local defaults instead of global defaults $form->setDefaults(Qs_Array::get($defaults, $name, [])); } return $this; } public function isValid($data) { if (!is_array($data)) { throw new \Zend_Form_Exception(__METHOD__ . ' expects an array'); } $translator = $this->getTranslator(); $valid = true; $formData = $data; $context = $data; foreach ($this->getElements() as $key => $element) { if (null !== $translator && $this->hasTranslator() && !$element->hasTranslator()) { $element->setTranslator($translator); } $check = $data; if (!isset($check[$key])) { $valid = $element->isValid(null, $context) && $valid; } else { $valid = $element->isValid($check[$key], $context) && $valid; } } foreach ($this->getSubForms() as $key => $form) { if (null !== $translator && $this->hasTranslator() && !$form->hasTranslator()) { $form->setTranslator($translator); } $valid = $form->isValid(Qs_Array::get($formData, $key, [])) && $valid; } $this->_errorsExist = !$valid; // If manually flagged as an error, return invalid status if ($this->_errorsForced) { return false; } return $valid; } public function isValidPartial(array $data) { $formData = $data; $translator = $this->getTranslator(); $valid = true; $context = $data; foreach ($this->getElements() as $key => $element) { $check = $data; if (isset($check[$key])) { if (null !== $translator && !$element->hasTranslator()) { $element->setTranslator($translator); } $valid = $element->isValid($check[$key], $context) && $valid; } } foreach ($this->getSubForms() as $key => $form) { if (null !== $translator && !$form->hasTranslator()) { $form->setTranslator($translator); } $valid = $form->isValidPartial(Qs_Array::get($formData, $key, [])) && $valid; } $this->_errorsExist = !$valid; return $valid; } }