I am not sure whether it is a topic or concept in the whole web development context, but when it comes to Laravel, the Php framework, I faced with this word (bag, or error bag) number of times, but I did not understand what does it exactly mean. Can anyone explain it? Thanks...
CodePudding user response:
accord to laravel document:
If you have multiple forms on a single page, you may wish to name the MessageBag
containing the validation errors, allowing you to retrieve the error messages for a specific form. To achieve this, pass a name as the second argument to withErrors
:
return redirect('register')->withErrors($validator, 'login');
You may then access the named MessageBag
instance from the $errors
variable:
{{ $errors->login->first('email') }}