Bad Request #400

Hi all. The objective is to create a drop menu that will produce a brand_id which will in turn produce products based on that brand selection. I’m hoping someone can look at this code and tell me where I’ve went astray in my efforts to capture an id from a dropdown. This might be a slight step forward as previously I was unable define the $model properly. Thanks in advance for your help.


 	 public function actionIndex($id)


			$model= Brands::findOne($id)

	        ->where(['brand_id' => 'id']);


			if ($id=== null) {

		echo 'This is a bad start';	


			throw new NotFoundHttpException;

			} else {

		echo 'This is a good start';	


		$query = Products::find()

	        ->where(['brand_id' => $id])

		->joinWith(['power', 'categories']);


		 $pagination = new Pagination([

            'defaultPageSize' =>4,

            'totalCount' => $query->count(),



		$products = $query






        return $this->render('index', [

            'products' => $products,

            'pagination' => $pagination,





   <?= $this->render('_form', [

        'model' => $model,

    ]) ?>


    <?= $form->field($model, 'brand_id', [

    'horizontalCssClasses' => [

    'wrapper'  => 'col-sm-3',


    ['prompt'=>' ----- Choose a Brand -----']) ?>

What mean $id here ?

Thank you for your reply. I was hoping to pull the id for brands here. If I remove the $id in question, id is once again undefined. I had tried the below actionView($id) earlier and did not define the variable properly. I’m obviously not grasping what I need from the 2.0 guide. Is there anywhere I can go to see specifically how the controller is written for a drop down used for the purposes of viewing only? I have a comparable menu working for the purposes of creating and saving records, but that was pretty much straight forward as it was a tutorial or something similar.

Controller should not contain code for dropdowns.

Better to get values for dropDownList in a view or a form.

dropDownList do not use pagination.

Look at ListView widget.(or AjaxDropDown)