示例#1
0
文件: Form.php 项目: ebuildy/ebuildy
 /**
  * 1. Set data of children
  * 2. Merge children norm validation error
  * 3. Set form data
  * 
  * @param array $value
  */
 public function setData($value)
 {
     foreach ($this->children as $child) {
         if (isset($value[$child->name])) {
             $child->setData($value[$child->name]);
         } else {
             $child->setData(null);
         }
     }
     foreach ($this->children as $child) {
         if ($child->isValid() === false) {
             foreach ($child->getErrors() as $errorName => $error) {
                 $this->errors[$child->name] = $error;
             }
         }
     }
     parent::setData($value);
 }