inspirenmy/yii2-traits

Yii2 traits library

Installs: 956

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Type:yii2-extension

v1.2.3 2017-09-21 03:51 UTC

This package is not auto-updated.

Last update: 2024-11-10 05:45:47 UTC


README

#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 inspirenmy\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';