hello,
i want to display one client data from table in _form create. but i got error
Yii2 Object of class … could not be converted to string.
error Object of class frontend\modules\cargo\models\Client could not be converted.
here is my action in 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,
]);
}
}
my _form file :
<div class="ask-goods-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->errorSummary($model); ?>
<?= $form->field($model, 'id', ['template' => '{input}'])->textInput(['style' => 'display:none']); ?>
<?= $form->field($model, 'policy_num')->textInput(['placeholder' => 'Policy Num']) ?>
<?= $form->field($model, 'cover_rate')->textInput(['placeholder' => 'Cover Rate']) ?>
<?= $form->field($model, 'deductible')->textInput(['maxlength' => true, 'placeholder' => 'Deductible']) ?>
<?= $form->field($model, 'attachment')->textInput(['placeholder' => 'Attachment']) ?>
<?= $form->field($model, 'id_client')->widget(\kartik\widgets\Select2::classname(), [
'data' => \yii\helpers\ArrayHelper::map(\backend\modules\ask_marine_cargo\models\AskClient::find()->orderBy('id')->asArray()->all(), 'id', 'id'),
'options' => ['placeholder' => Yii::t('ask_marine_cargo', 'Choose Ask client')],
'pluginOptions' => [
'allowClear' => true
],
]); ?>
<?= $form->field($model, 'delete_on')->textInput(['placeholder' => 'Delete On']) ?>
<?= $form->field($model, 'printed_at')->textInput(['placeholder' => 'Printed At']) ?>
<?= $form->field($client, 'insuranced_name') ?>
<?= $form->field($client, 'insuranced_name') ?>
could somebody help me ?