New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify yii\data\Sort to work also with $_POST #5498
Conversation
Currently `Sort` works only with `$_GET` sort parameter. Thus, for example combination of `GridView` and search form with method `post` does not work at all. Proposed change is an attempt to make `Sort` accept `$_POST` also. Example usage Search model: ``` ... $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => [ 'transaction_date' => SORT_DESC ], 'dataMethod' => 'post', 'formName' => $this->formName() ] ]); ... ``` GridView: ``` ... 'columns' => [ ... [ 'attribute' => 'transaction_date', 'sortLinkOptions' => [ 'data-method' => 'post', 'href' => '#', 'onclick' => 'jQuery(\'#'.Html::getInputId($searchModel, $dataProvider->getSort()->sortParam).'\').val(jQuery(this).data(\'sort\')).closest(\'form\').submit();' ], ], ... ``` Search form: ``` ... <?php echo Html::hiddenInput(Html::getInputName($model, $dataProvider->getSort()->sortParam), '', ['id' => Html::getInputId($model, $dataProvider->getSort()->sortParam)]); ?> ... ```
I'm afraid something similar will be nesessary to make pagination and forms with method |
I don't think we will support this by default. The |
????
|
|
Ok then, even it is not so obvious at first glance. But at list
could be implemented in |
Not quite sure. Why would you provide |
Take a look at
But as I dig into the |
Currently
Sort
works only with$_GET
sort parameter.Thus, for example combination of
GridView
and search form with methodpost
does not work at all.Proposed change is an attempt to make
Sort
accept$_POST
also.Example usage
Search model:
GridView:
Search form: