Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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">
    @csrf
    <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>
</form>

And this is the Controller method for updating:

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

But whenever I submit this, I get this error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading