Weird Give Data Is Invalid Error Message While Trying To Update


I have a Laravel 5.8 project and I have created this form for updating a title of a record:

<form action="{{ route('popups.update', ['id'=>$popup->id]) }}" method="POST">
    <label for="title" class="control-label">Title</label>
    <input type="text" id="title" name="title" class="form-control" value="{{ $popup->title }}">

    <button class="btn btn-success" type="submit">Submit</button>

And this is the Controller method for updating:

public function update(Request $request, $id)
        }catch (\Exception $e) {
        return redirect()->back();

But whenever I submit this, I get this error:

The given data was invalid.

I don’t really know what’s going wrong here? So if you know, please let me know…

>Solution :

If you are using Route::resource then method must be PUT/PATCH in form

Leave a Reply Cancel reply