Answer the question
In order to leave comments, you need to log in
Why does the error occur - Unable to link models: the primary key of app\models is null?
Hello everybody! I'm trying to link two tables Accept and Address. In the Accept controller in the Create action, I wrote the following:
$model = new Accept();
$model->link('address', new Address());
Unable to link models: the primary key of app\models\Accept is null.
public function getAddress(){
return $this->hasOne(Address::className(), ['accept_id' => 'id']);
}
public function getAccepts(){
return $this->hasMany(Accept::className(), ['id' => 'accept_id']);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question