freshwork/rut-field is a Laravel package for a laravel nova field..
It currently has 5 GitHub stars and 175 downloads on Packagist (latest version 1.1.2).
Install it with composer require freshwork/rut-field.
Discover more Laravel packages by freshwork
or browse all Laravel packages to compare alternatives.
Last updated
This package adds a Chilean RUT Field to Laravel Nova. It uses this composer package behind the scenes.
RutFielduse Freshwork\RutField\RutField;
// ...
public function fields(Request $request)
{
return [
RutField::make('rut')->rules('required|cl_rut');
]
}
By defaultm, on forms, it format the value on keyup. You can change this to blur.
RutField::make('rut')->formatOnBlur();
There are three possible formats:
COMPELTE 12.345.678-9
WITH DASH 12345678-9
ESCAPED 123456789
By default COMPLETE format is used, but you can change it.
RutField::make('rut')->formatComplete();
RutField::make('rut')->formatWithDash();
RutField::make('rut')->formatEscaped();
As you can check on this composer package, you can use cl_rut laravel validation.
If you need a custom validation error, you can override your resources/lang/es/validation.php. I personally use this package: https://github.com/caouecs/Laravel-lang
RutField::make('rut')->rules('required|cl_rut');
By default, the RUT value is always escaped (ESCAPED format) before saving to database. You can change this with saveWithoutNormalization saving the same text written by the user on the text field.
RutField::make('rut')->saveWithoutNormalization();
Also, you can validate the field using 'cl_rut' laravel validation included on this package: https://github.com/freshworkstudio/ChileanBundle
