在Yii2中,我有这样的搜索链接:localhost/project/web/?ItemSearch%5Btitle%5D=star
如何将其更改为:localhost/project/web/?title=star
这是我的表格
<?= $form->field($model, 'title') ?>看起来就像这样
<input type="text" name="ItemSearch[title]">当我试图将它更改为:
<input type="text" name="title">搜索不起作用,但链接看起来很好。
你知道怎么做吗?
发布于 2018-02-08 17:00:25
需要重写模型的formName方法才能返回空字符串
本质上,它将跳过输入的name属性中的模型名称(使用该模型的所有输入)。
class ItemSearch extends Model
{
public function formName() {
return '';
}
}https://stackoverflow.com/questions/48690235
复制相似问题