Answer the question
In order to leave comments, you need to log in
Why exit null value in related table?
The fact is that I have related tables, but it turns out that I get only id, but I tried it in wardump <?php var_dump($zakaz) ?>
, I get null
The code I wrote is this in the database model is connected
public function getIdZakaz()
{
return $this->hasOne(Zakaz::className(), ['id_zakaz' => 'id_zakaz']);
}
public function actionIndex()
{
$searchModel = new CourierSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$zakaz = Courier::findOne($id_zakaz);
$zakaz->IdZakaz->description;
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'zakaz' => $zakaz,
]);
}
[
'attribute' => 'id_zakaz',
'format' => 'text',
'value' => $zakaz,
],
public function attributeLabels()
{
return [
'id_zakaz' => '№',
....
'description' => 'Описание',
...
];
}
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