Skip to content
Yii2 chilean RUT formatting and validation
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
messages Initial commit Dec 22, 2014
tests extract{Number,DV}: return null if null input is given Aug 21, 2018
.editorconfig Add editorconfig file Aug 25, 2017
.gitignore Ignore composer.lock Nov 25, 2017
.travis.yml
LICENSE.md Convert indentation to spaces May 13, 2017
README.md Add travis badge Nov 30, 2017
Rut.php
RutFormatBehavior.php
RutValidator.php
RutValidatorAsset.php
RutWidget.php Import jquery.rut and add rut widget Jul 6, 2015
RutWidgetAsset.php
codeception.yml Add codeception tests Nov 25, 2017
composer.json Add codeception tests Nov 25, 2017

README.md

Build Status

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)

You can’t perform that action at this time.