This article is only for laravel developer.
MessageBag is a great tools in laravel php framework to send error message in previous page. In few days ago i fall in a problem to send some error message to view page. But i can't use it on validation of laravel and send error. i have several check of work. i have to overwrite MessageBag. so i use this simple syntax like below.
$message = new MessageBag([
'field_name' => ['Invalid input, Please try again.'],
]);
And send it on like this.
return redirect()->back()->withInput()->withErrors($message);
I have already have a view page where i want to show after submit this.
<div class="form-group{{ $errors->has('field_name') ? ' has-error' : '' }}">
<h3 class="payment-tittle">Insert your Input here</h3>
<input class="is_required validate account_input form-control {{ ($errors->has('field_name'))?"input-error":"" }}"
type="tel" name="otp" value="{{ old('field_name') }}" required>
@if ($errors->has('field_name'))
<span class="help-block"> {{ $errors->first('field_name') }} </span>
@endif
</div>
But i suggest all of you that use laravel validation process. But this process can be help you.
Top comments (0)