Loading Record with Listbox


I’m very much a newbie to the Yii2 framework, and have spent the last day trying to figure out how to load a record that is selected in a listbox. I’ve searched the forum for similar topics, but haven’t found any that have been of much help – likely because the solution is so simple that it’s taken for granted.

Any help or tips that could be given would be greatly appreciated. Here’s my code:


     $form = ActiveForm::begin();

     $model = new TestsitesSearch;

     $query = ArrayHelper::map(\common\models\Testsites::find()

          ->where(['UserID' => Yii::$app->user->identity->id])

          ->asArray()->all(), 'SiteID', 'BatchID');

     $htmloptions = array('style'=>'width:300px');

     echo $form->field($model, 'BatchID')->listbox($query, $htmloptions);

     echo Html::a('Load Existing Record', ['view', 'SiteID' => $model->SiteID], ['class' => 'btn btn-success']);



The query above successfully populates the listbox with the user’s records, but I haven’t been able to find a way to pass the selected value’s SiteID in the listbox to the “Load Existing Record” button. As such, when clicking on this button I get a message “Bad Request (#400): missing required parameters ‘SiteID’”.

I know I’m being stupid here, but what am I missing in order to pass the parameter to the button?