I'm trying to submit a form in my Blade template to the patient/update route using the POST method. In my controller, I want to inspect the submitted data using dd($request).
However, when I click the "Save" button, I get this error:
405 Method Not Allowed
I'm not sure what I'm doing wrong. How can I properly send the form data to the controller?
"The GET method is not supported for this route."
I’ve double-checked that my form is using the POST method. Here’s what I’ve tried so far:
View: blade
<form action="{{ route('patient/update') }}" metdod="post">
@csrf
<!-- Form contents -->
<input type="submit" class="btn btn-primary" value="Save">
</form>
Route: web.php
Route::post('/patient/update', 'PatientController@update')->name('patient/update');
Controller: PatientController
public function update(Request $request)
{
dd($request);
}
What could be causing Laravel to think this is a GET request, and how can I fix it?
The issue is in the very first line of your Blade file, where you misspelled "method":
<form class="" action="{{ route('patient/update') }}" metdod="post">
^^^^^^
Without a valid method
attribute in the form
tag, the request will default to a GET
.