P7rck
P7rck

Reputation: 156

JSvalidator for Laravel Backpack

How can I use JSvalidator like proengsoft/laravel-jsvalidation in backpack?

I know that you can edit the request rules for validation, but that's not what I want. I want a field to be validated onchange, onkeyup and etc. and JSvalidator libraries can help me big, instead of doing it manually.

Upvotes: 0

Views: 215

Answers (1)

tabacitu
tabacitu

Reputation: 6203

This is kind of a hack... but it works. What I did when I needed extra JS in my operations (in your case Create&Update) is that I created a Backpack Widget that will include the extra JS I need. And then I use that widget on those operations. This translates to something like a product_validation.php file:

@push('after_scripts')
    <script>
      // your custom code here
    </script>
@endpush

and then doing:

public function setupCreateOperation() {
        Widget::add()
            ->to('after_content')
            ->type('product_validation')
            ->content(null);
}

Upvotes: 1

Related Questions