Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit f84f6e4

Browse files
committed
Explaining future differences from the original package
1 parent 6c1beeb commit f84f6e4

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#Laravalid
2-
#### Laravel Validation For Client Side
1+
#Laravalid + Ardent
2+
#### Laravel Validation For Client Side, using self-validating smart models from Ardent
33

4-
This package makes validation rules defined in laravel work client-side by converting to html/js plugins such as jquery validation. It also allows to use laravel validation messages so you can show same messages for both sides.
4+
This package makes validation rules defined in Laravel work in the client by converting validation rules to HTML + JS plugins (such as jQuery Validation). It also allows you to use Laravel validation messages so you can show the same messages on both sides.
55

66

77
### Table of contents
@@ -73,15 +73,16 @@ After publishing configuration file, you can find it in config/laravalid folder.
7373

7474
### Usage
7575

76-
The package uses laravel Form Builder to make validation rules work for both sides. Therefore you should use Form Builder. While opening form by using Form::open you can give $rules as second parameter:
76+
The package uses Laravel Form Builder to make validation rules work for both sides. While opening a form by using `Form::open` you can pass the $rules as the second parameter:
7777
```php
7878
$rules = ['name' => 'required|max:100', 'email' => 'required|email', 'birthdate' => 'date'];
79-
Form::open(array('url' => 'foo/bar', 'method' => 'put'), $rules);
79+
Form::open(['url' => 'foo/bar', 'method' => 'put'], $rules);
8080
Form::text('name');
8181
Form::text('email');
8282
Form::text('birthdate');
8383
Form::close(); // don't forget to close form, it reset validation rules
8484
```
85+
8586
Also if you don't want to struggle with $rules at view files, you can set it in Controller or route with or without form name by using Form::setValidation($rules, $formName). If you don't give form name, this sets rules for first Form::open
8687
```php
8788
// in controller or route
@@ -99,6 +100,16 @@ For rules which is related to input type in laravel (such as max, min), the pack
99100
```
100101
The converter assume input is string by default. File type is not supported yet.
101102

103+
#### Usage with Ardent
104+
105+
The magic from this package extension, though, comes from the integration with Ardent models. Here are two ways to use it with Ardent (the second being the preferred one):
106+
```php
107+
// you can bring in the rules from the model...
108+
Form::open(['url' => 'foo/bar', 'method' => 'put'], App\Models\User::$rules);
109+
// ...or use the model form to make things even cleaner: the rules will be imported from it!
110+
Form::model($user, ['url' => 'foo/bar', 'method' => 'put']);
111+
```
112+
102113
**Validation Messages**
103114

104115
Converter uses validation messages of laravel (app/lang/en/validation.php) by default for client-side too. If you want to use jquery validation messages, you can set useLaravelMessages, false in config file of package which you copied to your config dir.

0 commit comments

Comments
 (0)