I add such select in the view
<select name="list"> <option value="mouse">mouse</option> <option value="keyboard">keyboard</option> <option value="headphones">headphones</option> </select>
In the model created
$list = Yii::$app->request->post('list', 'mouse') $result = Yii::$app->getDb()->createCommand(' Select * from order_table where items_sort in :list ')->bindValue(':list', '('.$list.')') ->queryAll(); return $result; }
The controller looks like this
public function actionIndex() { $data = null; if(isset($_GET['last_month'])) { $data = order::getTest(); } $dataProvider = new ArrayDataProvider([ 'allModels' => $data, 'sort' => [ ], 'pagination' => [ 'pageSize' => 50, ], ]); return $this->render('index',['dataProvider' =>$dataProvider]); }
But when selecting any value, the default value is substituted into the query. What could be the problem? Form Code
<div style="width: 25%; margin: 0 auto; text-align: center;"><br> <?php $form1 = ActiveForm::begin(['id' => 'last_month', 'method' => 'GET']); ?> <input type="hidden" value="0" name="last_month"> <div class="form-group" style="float:left;margin-left: 5px;"> <?= Html::submitButton('Прошлый <br> месяц', ['class' => 'btn btn-primary', 'name' => 'n1', 'style'=>"width:120px;display:inline-block;"]) ?> </div> <?php ActiveForm::end(); ?> <?php $form = ActiveForm::begin(['id' => 'pre_last_month', 'method' => 'GET',]) ?> <input type="hidden" value="1" name="pre_last_month"> <div class="form-group" style="float:left;margin-left: 5px;"> <?= Html::submitButton('Позапрошлый <br> месяц', ['class' => 'btn btn-primary', 'name' => 'nn',]) ?> </div> <div style="clear:both;"></div> <?php ActiveForm::end(); ?></div> <form method=post> <select name="list"> <option value="vari-cream-com">vari-cream-com</option> <option value="joint-cream">joint-cream</option> <option value="gemor-cream">gemor-cream</option> </select> </form>