Reputation: 73
I am passing a value($model->stop) of my form to controller action(search2) via button click.But I can't get that value in the controller.
view:
<?= Html::a(Yii::t('app', 'Search'), ['search2','id' => $model->stop], ['class' => 'btn btn-success'])
Controller:
public function actionSearch2($id)
{
if ($model->load(Yii::$app->request->post())) {
$searchModel = new ScheduleRouteSearch();
$dataProvider1 = $searchModel->search1(Yii::$app->request- >queryParams, $id);
return $this->render('search', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider1,
]);
}
}
Error:
Bad Request (#400)
Missing required parameters: id
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.
Help me to solve this.
Upvotes: 1
Views: 434
Reputation: 773
All your code seems right, I think problem is with $model->stop value
$model->stop // value might be null --null value also gives missing parameter error
please check.
Upvotes: 2