When I remove the ‘action’ => Url::to([‘index’]) from the ActiveForm::begin the form search and the gridview header search work side by side, but the url is increasing.
When I run it like show in the example, the url is not increasing, but if I submit the form, the header search parameters will be overwritten.
I hope you can understand my issue.
If you have further questions just ask. I am thankful for every hint
As you have noticed, you need to set ‘action’ parameter of the search form to “Url:to([‘index’])” (or, just “[‘index’]”) in order to keep the url from getting long.
$form = ActiveForm::begin([
'id' => 'orders-search-form',
'method' => 'GET',
'action' => Url::to(['index']),
/* 'action' => ['index'], */ /* this is OK, too */
]);
This is because ActiveForm will set its action to the current url by default. Once the search result has been displayed, then the current url should contain the search parameters in it. So we have to set the url without the search parameters explicitly.
It’s not possible to avoid the synchronization of the search parameters between the search form and the gridview filter, as long as they share the same search model. And IMO it is also what users expect. I don’t want the parameters with the same name having different values in the form and in the filter.
But, I think you may consider having hidden fields in the search form. They will preserve the search parameter values of the filter.