Php 如何在yii2中执行简单的搜索表单/功能?
我想做一个搜索使用的形式,将搜索名称字段,品牌字段和类别字段Php 如何在yii2中执行简单的搜索表单/功能?,php,model-view-controller,yii2,Php,Model View Controller,Yii2,我想做一个搜索使用的形式,将搜索名称字段,品牌字段和类别字段 在这种情况下,我应该使用post还是get 如何/在何处创建查询搜索模型、模型或控制器 任何代码片段都很好 我认为: <?php $form = ActiveForm::begin(['id' => 'home-search','method' => 'get', 'action' => Url::to(['productitem/search'])]); ?> <?= $form->
<?php $form = ActiveForm::begin(['id' => 'home-search','method' => 'get', 'action' => Url::to(['productitem/search'])]); ?>
<?= $form->field($productitem, 'name')->textInput(array('placeholder' => 'What are you looking for?'))->label(false) ?>
<?= $form->field($productitem, 'brand_id')->dropDownList(
ArrayHelper::map(ProductBrand::find()->all(),'id','name'),
['prompt'=>'Select Brand']
)->label(false) ?>
<?= $form->field($productitem, 'category_id')->dropDownList(
ArrayHelper::map(ProductCategory::find()->all(),'id','name'),
['prompt'=>'Select Department']
)->label(false) ?>
<div class="form-group search-button">
<button type="submit" class="btn btn-primary" name="login-button">Search <i class="fa fa-lg fa-arrow-circle-o-right"></i></button>
</div>
<?php ActiveForm::end(); ?>
搜寻
您的问题的答案: