我有一个视图,我在其中使用了GridView
and DetailView
。在我的控制器中,我通过它的 ID 发送模型。所以以这种方式我GridView
的工作。
控制器 1
public function actionViewcreated($id)
{
$model=$this->findModel($id);//the id of created form
/*print_r($model);
exit();*/
$id = $model->id;
$created_by = $model->created_by;
$issuer = $model->issuer;
$store = $model->store_id;
$admin = $model->admin_incharge;
$pm = $model->project_manager;
.....
// my other code
return $this->render('viewcreated', [
'dataProvider' => $dataProvider,
'model' => $this->findModel($id),
'id'=> $model->id
/*'searchModel' => $searchModel*/
]);
}
看法
$this->title = $model->id;
$this->title = 'Outward Gate Pass';
$this->params['breadcrumbs'][] = $this->title;
.
.
.
.
<?= DetailView::widget([
'model' => $model,
'attributes' => [
//'id',
[
'label'=>'OGP Serial #',
'value' => function($d)
{
return $d->id;
}
],
[
'label' => 'Created By',
'value' => function ($d) {
if(is_object($d))
return $d->created->name;
},
/* 'filter' => Html::activeDropDownList($searchModel, 'created_by', \app\models\User::toArrayList(), ['prompt' => "Users", 'class' => 'form-control']),*/
],
'created_at',
[
'label' => 'Store',
'value' => function ($d) {
if(is_object($d))
return $d->store->name;
return ' - ';
},
//'filter' => Html::activeDropDownList($searchModel,'store_id',\app\models\Stores::toArrayList(),['prompt' => "Stores", 'class'=>'form-control']),
],
'status',
[
'label' => 'Issued To',
'value' => function ($d) {
if(is_object($d->user))
return $d->user->username;
return ' - ';
},
//'filter' => Html::activeDropDownList($searchModel, 'issuer', \app\models\User::toArrayList(), ['prompt' => "Users", 'class' => 'form-control']),
],
'admin_incharge',
'project_manager',
],
]) ?>
<br>
<?= GridView::widget([
'dataProvider' => $dataProvider,
/*'filterModel' => $searchModel,*/
'columns' => [
['class' => 'yii\grid\CheckboxColumn'],
'Meter Serial Number',
'Issued To',
'Store',
],
]); ?>
<form>
<p>
<a href="<?= URL::toRoute('ogpheader/viewsetpdf')?>" type="submit" class="btn btn-primary" name="issue_pdf">Set PDF</a>
<br/>
</p>
</form>
结果视图:
现在想将我的两者都发送GridView
到DetailView
一个新的控制器中。为了
新控制器
public function actionViewsetpdf($id)
{
$model = $this->findModel($id);
print_r($model);
exit();
}
在这里,我只想查看模型中的值。但是当我点击Set PDF
按钮时,我总是得到
错误请求 (#400) 缺少必需参数:id
我坚持下去,因为我不知道为什么它没有向我显示数据。
任何帮助将不胜感激。