demmonico / yii2-traits
Yii2 traits library
Installs: 2 365
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >5.5.0
- demmonico/yii2-helpers: *
- yiisoft/yii2: ~2.0.0
This package is not auto-updated.
Last update: 2024-11-19 04:37:06 UTC
README
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
!!! This trait is DEPRECATED Use demmonico/reflection instead!!!
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';