Bird
0
0

What does the Blade directive @csrf do inside a form?

easy📝 Conceptual Q2 of 15
Laravel - Views and Blade Templates
What does the Blade directive @csrf do inside a form?
AStarts a new form tag
BIncludes a JavaScript file
CValidates form input automatically
DAdds a hidden token to protect against cross-site request forgery
Step-by-Step Solution
Solution:
  1. Step 1: Understand CSRF protection in Laravel forms

    Laravel protects forms from cross-site request forgery by adding a hidden token.
  2. Step 2: Identify the Blade directive that adds this token

    @csrf inserts a hidden input with the CSRF token inside the form.
  3. Final Answer:

    Adds a hidden token to protect against cross-site request forgery -> Option D
  4. Quick Check:

    @csrf = CSRF token hidden input [OK]
Quick Trick: Use @csrf inside forms to add security token [OK]
Common Mistakes:
  • Thinking @csrf starts a form
  • Assuming @csrf validates inputs
  • Confusing @csrf with script inclusion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes