i want to show one data from table client when create data Goods, but i got error Object of class frontend\modules\cargo\models\Client could not be converted.
here is GoodsController
public function actionCreate()
{
$model = new Goods();
$idClient = Yii::$app->user->identity->id_client;
$client = Client::find($idClient)->one();
if ($model->loadAll(Yii::$app->request->post()) && $model->saveAll()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
'client' => $client,
]);
}
}
I need to display data client in _form Goods.somebody could help me?