From 1bbf5682976deb374e6433c49bc181ece34e1593 Mon Sep 17 00:00:00 2001 From: rogal127 <37405360+rogal127@users.noreply.github.com> Date: Sun, 27 Sep 2020 15:24:08 +0200 Subject: [PATCH] Update inertia.md --- 1.x/stacks/inertia.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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