sateler / yii2-rut
添加智利RUT格式化和验证功能
2.0.5
2019-02-26 13:59 UTC
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
- codeception/codeception: ^2.3
README
RUT格式化
在 config/web.php
中加载行为
'formatter' => [
'class' => \yii\i18n\Formatter::className(),
'as rutFormatter' => \sateler\rut\RutFormatBehavior::className(),
],
如果使用其他格式化类,请添加行为
public function behaviors() {
return [ \sateler\rut\RutFormatBehavior::className() ];
}
然后可以使用 Yii::$app->formatter->asRut()
,或在 GridView
或 DetailView
中指定 rut
格式。
RUT验证器
在你的模型规则中添加
['property', \sateler\rut\RutValidator::className()]
RUT小部件
在您的应用资源中添加,以在textInputs中格式化输入数据
public $depends = [
...,
'sateler\rut\RutWidgetAsset',
];
并使用以下方式激活文本输入
$form->field($model, "rut")->textInput(['data-rut' => 'true'])
从1.x升级到2.x
只需将对 RutValidator::trimValue($value)
的引用替换为新函数 Rut::normalize($value)