demmonico/yii2-traits Yii2 traits library

extensioncomponenttrait

Yii2 traits library

Description

Yii2 traits library which used in web-application development.

Composition

AjaxValidationTrait

Trait add perform ajax validation to models and forms.

Usage:

use demmonico\models\Model as parent or set in you model

use AjaxValidationTrait;

in controller

if (!is_null($validate = $model->performAjaxValidation()))
            return $validate;

ConstantTrait

Trait generates array of class constant labels or one label by constant value

Usage:

set in your model

use ConstantTrait;

const NAME_FIRST = 1;
const NAME_SECOND = 2;

then anywhere get array values and names of constants:

ModelName::getName();   // returns array(1 => 'First', 2 => 'Second');

or

$model->getName();      // returns array(1 => 'First', 2 => 'Second');

Whether get name by constant value:

ModelName::getName(ModelName::NAME_FIRST);   // returns 'First';

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v1.2.1 is the latest of 7 releases



MIT license
Stats
0 github stars & 0 github forks
0 downloads in the last day
6 downloads in the last 30 days
58 total downloads