Answer the question
In order to leave comments, you need to log in
How to avoid warning on beforeValidate() in Yii2?
Good afternoon.
I want to get rid of the warning (and understand what's wrong), but I don't understand why it occurs.
In a model that inherits from active record, I have a method
public function beforeValidate() {
//shopinf
if(!empty( $shopinf = Yii::$app->Union->getProfile([
'user'=>Yii::$app->User->getUser()
]) )){
$this->shopinf = $shopinf['id'];
}
return parent::beforeValidate();
}
public function beforeValidate($data) {
//shopinf
if(!empty( $shopinf = Yii::$app->Union->getProfile([
'user'=>Yii::$app->User->getUser()
]) )){
$this->shopinf = $shopinf['id'];
}
return parent::beforeValidate($data);
}
public function beforeValidate() {
//shopinf
if(!empty( $shopinf = Yii::$app->Union->getProfile([
'user'=>Yii::$app->User->getUser()
]) )){
$this->shopinf = $shopinf['id'];
}
//return parent::beforeValidate();
}
Answer the question
In order to leave comments, you need to log in
public function beforeValidate() {
//shopinf
if (!empty( $shopinf = Yii::$app->Union->getProfile(['user'=>Yii::$app->User->getUser()]))) {
$this->shopinf = $shopinf['id'];
}
if (parent::beforeValidate()) {
return true;
}
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question