Open Verbat opened 7 years ago
Try extending the model in the Plugin.php inside the boot function.
use RainLab\User\Models\User;
public function boot()
{
User::extend(function($model) {
$model->bindEvent('model.beforeValidate', function() use ($model) {
$model->addFillable([
'custom_field',
]);
$model->rules = [
'custom_field' => ['required']
];
});
});
}
Is it possible to extend the validation rules to make it more specific? Let's say I create a field in the backend and set it to text, now I also want to limit it to max x characters or compare it to another field.
I'm perfectly fine with extending the rules at the page code section but I'm not quite sure where to start. Would be great if you can point me in the right direction or show how to do it as with the build in validation there are a lot of possibilities where this might be usefull. Thanks