Answer the question
In order to leave comments, you need to log in
Why does the Call to a member function load() on null error occur?
Actually here is the code
$model= new Watch();
if($this->classes == 'serial'){
$feild='id_serial';
$model= $model->id_serial;}
if($this->classes == 'film'){
$feild='id_film';
$model= $model->id_film;}
if($this->classes == 'mfilm'){
$feild='id_mfilm';
$model= $model->id_mfilm;}
$wathCount= Watch::find()->where(['id_serial'=>$this->serial->id,'active'=>1])->count();
$guest=false;
if ($model->load(Yii::$app->request->post()))
{ ...
Answer the question
In order to leave comments, you need to log in
because you are overwriting the $model variable in three places
if($this->classes == 'serial'){
$feild='id_serial';
$model= $model->id_serial;} // тут
if($this->classes == 'film'){
$feild='id_film';
$model= $model->id_film;} // тут
if($this->classes == 'mfilm'){
$feild='id_mfilm';
$model= $model->id_mfilm;} // тут
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question