What is the hasErrors () method used for? It is not clear to us, can someone help, tell me how to interpret its description correctly?
Returns
Returns the value of the indicator / pointer when it finds any error.
We do not know how to understand this.
http://www.yiiframework.com/doc-2.0/yii-base-model.html#hasErrors()-detail
public function validatePassword($attribute, $params) { if (!$this->hasErrors()) { $user = $this->getUser(); if (!$user || !$user->validatePassword($this->password)) { $this->addError($attribute, 'Incorrect username or password.'); } } }
true/false
....... there are errors - returnstrue
, there were no errors during the check - returnsfalse
... .... and does not return pointers / indicators .... where did you find such a translation .... - Alexey Shimanskyvalidate()
method do the same? I understand that you could justvalidate()
call instead ofhasErrors()
. If it doesn't bother you, could you give your answer, in the form of an answer, for future users? - FiRvalidate
course a wrapper overhasErrors
and in the result of its workreturn !$this->hasErrors()
, but at the same time it itself is deeper, because There are many other various checks inside (you can even look atModel.php -> validate()
), and also applybeforeValidate
andafterValidate
where there can still be a bunch of any checks ... and in fact apply to a specific script ... ....hasErrors
not tied to scripts, just a dull little simple method - Alexey Shimansky