inspirenmy / yii2-traits
Yii2 traits library
Installs: 956
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Type:yii2-extension
Requires
- php: >5.5.0
- demmonico/yii2-helpers: *
- yiisoft/yii2: ~2.0.0
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';