alexanoid
alexanoid

Reputation: 25862

Yii2 remove form name from url parameters

I use Yii2 forms and after submit my URL looks like:

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

As you may seem each parameter contains form name RecommendationSearch. How to remove this RecommendationSearch from parameters in order to get URL url like the following:

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

Upvotes: 0

Views: 962

Answers (1)

rob006
rob006

Reputation: 22174

You need to override formName() in your RecommendationSearch model to return empty string:

public function formName() {
    return '';
}

Upvotes: 3

Related Questions