Reputation: 119
My Form in the edit view:
<form class="form-horizontal" role="form" method="PUT" action="{{ route('locations.update', $location->id) }}">
{{ csrf_field() }}
// All form Fields ...
</form>
My routs for this case:
| GET|HEAD | locations/create | locations.create | App\Http\Controllers\LocationController@create
| PUT|PATCH | locations/{location} | locations.update | App\Http\Controllers\LocationController@update
| GET|HEAD | locations/{location} | locations.show | App\Http\Controllers\LocationController@show
| DELETE | locations/{location} | locations.destroy | App\Http\Controllers\LocationController@destroy
My update method in the locations controller
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
dd($request);
}
The result on form submitting the dd($request); result is not showing up.
Any hints for me what i am doing wrong here?
Thanks a lot!
Upvotes: 0
Views: 1693
Reputation: 33186
Web browsers don't support PUT
routes, only GET
and POST
. To solve this, you can use Form Method Spoofing By adding a hidden field to your form. Like so:
<form class="form-horizontal" role="form" method="post" action="{{ route('locations.update', $location->id) }}">
{{ csrf_field() }}
<input type="hidden" name="_method" value="PUT">
// All form Fields ...
</form>
Upvotes: 4