Bird
0
0

How can you retain old input values in a Laravel Blade form text input after validation fails?

hard📝 Application Q9 of 15
Laravel - Request and Response
How can you retain old input values in a Laravel Blade form text input after validation fails?
A{{ Form::text('name', old('name')) }}
B{{ Form::text('name', request('name')) }}
C{{ Form::text('name') }}
D{{ Form::text('name', session('name')) }}
Step-by-Step Solution
Solution:
  1. Step 1: Understand old() helper usage

    old('name') retrieves the previous input value after validation failure.
  2. Step 2: Use old() as default value in Form::text

    Passing old('name') as second parameter sets the input value to previous user input.
  3. Final Answer:

    {{ Form::text('name', old('name')) }} -> Option A
  4. Quick Check:

    Use old() helper to retain input values [OK]
Quick Trick: Use old('field') to keep input after validation errors [OK]
Common Mistakes:
  • Using request() instead of old()
  • Not passing any default value
  • Trying to use session() directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes