Пример #1
0
 public function validate($attributeNames = null, $clearErrors = true)
 {
     if ($clearErrors) {
         $this->clearErrors();
     }
     if (!$this->beforeValidate()) {
         return false;
     }
     if (!$this->model->validate($attributeNames, $clearErrors)) {
         foreach ($this->model->getErrors() as $attribute => $errors) {
             foreach ($errors as $error) {
                 $this->addError($attribute, $error);
             }
         }
     }
     foreach ($this->relations as $model) {
         if (!$model->validate($attributeNames, $clearErrors)) {
             foreach ($model->getErrors() as $attribute => $errors) {
                 foreach ($errors as $error) {
                     $this->addError($attribute, $error);
                 }
             }
         }
     }
     $this->afterValidate();
     return !$this->hasErrors();
 }