sateler / yii2-rut
Add chilean RUT formatting and validation
Installs: 3 002
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
- codeception/codeception: ^2.3
README
Rut Formatting
Load the behavior in the config/web.php
:
'formatter' => [
'class' => \yii\i18n\Formatter::className(),
'as rutFormatter' => \sateler\rut\RutFormatBehavior::className(),
],
Or if you use another formatter class, add the behavior:
public function behaviors() {
return [ \sateler\rut\RutFormatBehavior::className() ];
}
Then you can use Yii::$app->formatter->asRut()
, or specify the rut
format in GridView
or DetailView
.
Rut Validator
In your model rules, add:
['property', \sateler\rut\RutValidator::className()]
Rut Widget
To format input data in textInputs, in your app assets, add:
public $depends = [
...,
'sateler\rut\RutWidgetAsset',
];
And activate the text input using:
$form->field($model, "rut")->textInput(['data-rut' => 'true'])
Upgrade from 1.x to 2.x:
Just replace references to RutValidator::trimValue($value)
to the new function Rut::normalize($value)