Support the ongoing development of Laravel.io →
Requests Input Validation
Last updated 2 years ago.
0

To mark the error and show the error message, you use the $errors variable. here's a shorter way

<div {{ $errors->first('field') ? 'class="error"' : '' }}>

To fill old inputs in your view after redirection with errors, you juste need to add this

<input type="text" name="field" value="{{ old('field') }}">

PS: i'm not sure if FormRequest redirect with inputs. PS2 : file fields are not flashed in session.

0

Hello, @othmanus. Thank you, for your reply! It helped me a lot!

{{ old('field' }}

is working. So now I have everything I need. I can do something like

{{ $errors->first('field') ? '' : old('field') }}

We can close the topic, I think.

0

soanvig said:

Hello, @othmanus. Thank you, for your reply! It helped me a lot!

{{ old('field' }}

is working. So now I have everything I need. I can do something like

{{ $errors->first('field') ? '' : old('field') }}

We can close the topic, I think.

I don't think there's a need for this, because {{ old('field') }} is empty when you have no input in session.

0

othmanus said: I don't think there's a need for this, because {{ old('field') }} is empty when you have no input in session.

Yup, but I want to have empty field, if that field was incorrect, and filled, when field was correct.

0

soanvig said:

othmanus said: I don't think there's a need for this, because {{ old('field') }} is empty when you have no input in session.

Yup, but I want to have empty field, if that field was incorrect, and filled, when field was correct.

My bad, in that case you're right ^_^

0

Sign in to participate in this thread!

Eventy

Your banner here too?

soanvig soanvig Joined 26 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.