diff --git a/1.x/stacks/inertia.md b/1.x/stacks/inertia.md index 457ca40..2d74f9e 100644 --- a/1.x/stacks/inertia.md +++ b/1.x/stacks/inertia.md @@ -89,6 +89,38 @@ this.form.post('/user/profile-information', { }) ``` +To validate the form on back-end, you should use `Validator` + +```php + +all(), [ + 'title' => 'required|max:200', + 'description' => 'required|min:50', + ])->validateWithBag('createTask'); + + $task = new Task(); + $task->title = $request->title; + $task->description = $request->description; + $task->owner = Auth::user()->id; + $task->save(); + + return back(); + } +``` + Form error messages may be accessed using the `form.error` method. This method will return the first available error message for the given field: ```html