yii\base\Model::getFirstErrors PHP 메소드

getFirstErrors() 공개 메소드

Returns the first error of every attribute in the model.
또한 보기: getErrors()
또한 보기: getFirstError()
public getFirstErrors ( ) : array
리턴 array the first errors. The array keys are the attribute names, and the array values are the corresponding error messages. An empty array will be returned if there is no error.
    public function getFirstErrors()
    {
        if (empty($this->_errors)) {
            return [];
        } else {
            $errors = [];
            foreach ($this->_errors as $name => $es) {
                if (!empty($es)) {
                    $errors[$name] = reset($es);
                }
            }
            return $errors;
        }
    }

Usage Example

예제 #1
0
 /**
  * @return array
  */
 public function getErrors()
 {
     if (empty($this->_errors)) {
         foreach ($this->_model->getFirstErrors() as $name => $message) {
             $this->_errors[] = ['field' => $name, 'message' => $message];
         }
     }
     return $this->_errors;
 }
All Usage Examples Of yii\base\Model::getFirstErrors