Yii2从URL参数中删除表单名称

时间:2018-07-11 18:20:07

标签: yii yii2 yii-form

我使用Yii2表格,提交后,我的网址如下:

http://example.com/recommendations/index?RecommendationSearch%5Bname%5D=&RecommendationSearch%5Bstatus_id%5D=&RecommendationSearch%5Btype%5D=0&RecommendationSearch%5Bcreated_at%5D=&sort=created_at

您似乎似乎每个参数都包含表单名称RecommendationSearch。如何从参数中删除此RecommendationSearch以获取如下所示的URL URL:

http://example.com/recommendations/?name=&status_id=&type=0&created_at=&sort=created_at

1 个答案:

答案 0 :(得分:2)

您需要在RecommendationSearch模型中覆盖formName()以返回空字符串:

public function formName() {
    return '';
}