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.
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.
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.
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.
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 ^_^
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community