PHPackages                             elmys/status-filter-behave - 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. elmys/status-filter-behave

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

elmys/status-filter-behave
==========================

Typical helper for show status-drop-list and validate sequence of them

0134PHP

Since Jan 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/elmys/status-filter-behave)[ Packagist](https://packagist.org/packages/elmys/status-filter-behave)[ RSS](/packages/elmys-status-filter-behave/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

status-filter-behave
====================

[](#status-filter-behave)

Typical helper for show status-drop-list and validate sequence of them

Why it's need for you
---------------------

[](#why-its-need-for-you)

Extension filter statuses for model by array of allowed statuses by sequence or/and permissons. Also work prevalidation. Your model should has additional table of status history and corresponding relation methods.

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

[](#installation)

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

- Either run

```
php composer.phar require --prefer-dist "elmys/status-filter-behave" : "master@dev"

```

or add

```
"elmys/status-filter-behave" : "master@dev"

```

to the require section of your application's `composer.json` file.

Usage
-----

[](#usage)

In your model of statuses:

```
// Import
use elmys\helpers\statusfilterbehave;

class YourStatusHistoryModel{

//constants section
const STATUS_ONE = 1; // status_one
const STATUS_TWO = 2; // status_two
const STATUS_THREE = 3; // status_three

const ALLOWED_STATUSES = [
        self::STATUS_ONE => [
            self::STATUS_TWO,
        ],
        self::STATUS_TWO => [
            self::STATUS_ONE,
            self::STATUS_THREE,
        ],
];

const STATUSES_BY_PERMISSIONS = [
        'permissionOne' => [
            self::STATUS_ONE,
        ],
];

//behave section
public function behaviors()
    {
        return [
            [
                'class' => StatusFilterBehave::class,
                'getParentMethodName' => 'order', // YourStatusHistoryModel->getOrder() = order
                //'sortListAsc' => false, // sort list of statuses
                //'parentStatusAttributeName' => 'current_status_id', // if general model store current status id and have different field name
                //'childStatusIdAttributeName' => 'status_id', // if model of statuses has different field name
                //'errorMsgEmptyStatus' => 'You must fill "Status"', // error message 1
                //'errorMsgWrongJumpStatus' => 'Incorrect sequence of statuses', // error message 2
                //'errorMsgPermission' => 'You haven\'t permission', // error message 3
            ],
        ];
    }
}
```

In activeForm view file:

```
// $model - model of statuses
