PHPackages                             i4erkasov/yii2-drop-down-list-sorter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. i4erkasov/yii2-drop-down-list-sorter

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

i4erkasov/yii2-drop-down-list-sorter
====================================

DropDownList Sorter for Yii2

1.0(3y ago)081MITPHPPHP ^7.1

Since Apr 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/i4erkasov/yii2-drop-down-list-sorter)[ Packagist](https://packagist.org/packages/i4erkasov/yii2-drop-down-list-sorter)[ RSS](/packages/i4erkasov-yii2-drop-down-list-sorter/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

DropDownList Sorter for Yii2
============================

[](#dropdownlist-sorter-for-yii2)

[![Latest Stable Version](https://camo.githubusercontent.com/277c735fbb820403a90441e110745d494870c7ee259d3e262cba5ac5d25d7e20/68747470733a2f2f706f7365722e707567782e6f72672f693465726b61736f762f796969322d64726f702d646f776e2d6c6973742d736f727465722f762f737461626c65)](https://packagist.org/packages/i4erkasov/yii2-drop-down-list-sorter)[![Total Downloads](https://camo.githubusercontent.com/eb68c7a32e68f1312f842feff602d98150bb2c51296b6a76dd90e39dcecee990/68747470733a2f2f706f7365722e707567782e6f72672f693465726b61736f762f796969322d64726f702d646f776e2d6c6973742d736f727465722f646f776e6c6f616473)](https://packagist.org/packages/i4erkasov/yii2-drop-down-list-sorter)[![License](https://camo.githubusercontent.com/9d3d0dd4d90fd4fbbc1db533f842dfdf4d260573c83387a4bee8521d7795c365/68747470733a2f2f706f7365722e707567782e6f72672f693465726b61736f762f796969322d64726f702d646f776e2d6c6973742d736f727465722f6c6963656e7365)](https://packagist.org/packages/i4erkasov/yii2-drop-down-list-sorter)

Yii2 widget to sort ActiveDataProvider data using a drop-down list.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Run the following command

```
php composer.phar require --prefer-dist i4erkasov/yii2-drop-down-list-sorter "*"

```

or add the following to the require section of your composer.json file:

```
"i4erkasov/yii2-drop-down-list-sorter": "*"

```

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

Add to our ActiveDataProvider in sort::

```
$dataProvider = new yii\data\ActiveDataProvider([
            'query'      => $query,
            'pagination' => [
                'pageSize'      => 32,
                'route'         => '/catalog/',
                'pageSizeParam' => false,
            ],
            'sort'       => new \i4erkasov\dropdownlistsorter\data\Sort([
                'route'        => '/catalog/',
                'unsetParams'  => ['page', '_pjax'],
                'attributes'   => [
                    'index' => [
                        'asc'   => ['sort_index' => SORT_ASC],
                        'desc'  => false,
                        'label' => ['asc' => Yii::t('app', 'default')],
                    ],
                    'name'  => [
                        'asc'   => ['name' => SORT_ASC],
                        'desc'  => false,
                        'label' => ['asc' => Yii::t('app', 'by name')],
                    ],
                    'price' => [
                        'asc'   => ['price' => SORT_ASC],
                        'desc'  => ['price' => SORT_DESC],
                        'label' => [
                            'asc'  => Yii::t('app', 'price asc'),
                            'desc' => Yii::t('app', 'price desc'),
                        ],
                    ],
                ],
                'defaultOrder' => [
                    'index' => SORT_ASC,
                ],
            ]),
        ]);
```

The set of parameters is the same as for standard [Yii2 Sort](https://www.yiiframework.com/doc/api/2.0/yii-data-sort)

For exclusively:

The defaultOrder parameter is required And Added the unsetParams parameter for exclude GET parameters, as shown above when generating the sort URL.

Example:

```
'unsetParams'  => ['page', '_pjax'],
```

php example:

```
echo \i4erkasov\dropdownlistsorter\widget\DropDownSorter::widget([
    'sort'       => $dataProvider->sort,
    'class'      => 'filter-select__select',
    'onchange'   => '$.pjax.reload({container: "#pjax-catalog", url: $(this).val()})',
    'attributes' => [
        'index',
        'name',
        'price',
    ],
]);
```

yii2-twig example:

```
{{ use('i4erkasov/dropdownlistsorter/widget/DropDownSorter') }}
{{ use('yii/widgets/Pjax') }}

{{ dropDownSorter_widget({
    'sort': dataProvider.sort,
    'options': {
        'class': 'filter-select__select',
        'onchange': '$.pjax.reload({container: "#pjax-catalog", url: $(this).val()})',
    },
    'attributes': [
        'index',
        'name',
        'price'
    ]
}) | raw }}

{{ pjax_end() }}
```

> **Note**Please note that in the above examples, the handling of the event for "change" DropDownList is implemented via pjax

```
'onchange': '$.pjax.reload({container: "#pjax-catalog", url: $(this).val()})',
```

License
-------

[](#license)

This package is released under the MIT License. See LICENSE.md for details.

Contributing
------------

[](#contributing)

You can contribute by submitting pull requests or creating new issues.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c06d91181eafb8cf50374b60d74f319aeefcff05b0425ea374823b34b58b998a?d=identicon)[i4erkasov](/maintainers/i4erkasov)

---

Top Contributors

[![i4erkasov](https://avatars.githubusercontent.com/u/44391984?v=4)](https://github.com/i4erkasov "i4erkasov (4 commits)")

---

Tags

yii2extension

### Embed Badge

![Health badge](/badges/i4erkasov-yii2-drop-down-list-sorter/health.svg)

```
[![Health](https://phpackages.com/badges/i4erkasov-yii2-drop-down-list-sorter/health.svg)](https://phpackages.com/packages/i4erkasov-yii2-drop-down-list-sorter)
```

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
