Bird
0
0

Given this Blade form snippet:

medium📝 component behavior Q13 of 15
Laravel - Request and Response
Given this Blade form snippet:
<form method="POST" action="/submit">
  @csrf
  <input type="text" name="username" value="John">
  <button type="submit">Send</button>
</form>

What will request('username') return in the controller after submission?
Anull
BAn error because value attribute is ignored
C"John"
D"username"
Step-by-Step Solution
Solution:
  1. Step 1: Understand form input and value attribute

    The input has name="username" and value="John", so the form sends "John" as the username.
  2. Step 2: Recall how Laravel's request() works

    Calling request('username') retrieves the submitted value for the input named "username".
  3. Final Answer:

    "John" -> Option C
  4. Quick Check:

    Input value sent = request('name') [OK]
Quick Trick: Input value attribute sets default sent data [OK]
Common Mistakes:
  • Thinking value attribute is ignored on submit
  • Expecting request('username') to return the name string
  • Confusing request() with old() helper

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes