简体   繁体   中英

How to update a Table from Form data in Laravel 5

I have a form in Laravel5

<form method="POST" action="http://localhost:8000/song/Baby/update" accept-charset="UTF-8">
    <input name="_method" type="hidden" value="PATCH">
    <input name="_token" type="hidden" value="kagIHsGe3zOZSPVyW6wW84Cn5eresZ2nlF287nNK">
    <div class="form-group">
        <input class="form-control" name="title" type="text" value="Baby">
    </div>
    <div class="form-group">
        <textarea class="form-control" name="lyrics" cols="50" rows="10">
            Yo Yo Yo BABY
        </textarea>
    </div>
    <div class="form-group">
        <input type="submit" value="Update Song">
    </div>        
</form>

Then in Route file I have written the code

patch('songs/Baby/update','SongsController@update');

Its throwing error

Sorry, the page you are looking for could not be found.

NotFoundHttpException in RouteCollection.php line 143:

Is the syntax changed for PATCH request in Laravel 5?

Your route and form action are different.

You have defined a route with songs (plural) and used as song (singular) in form action.

Try changing your form action to

action="http://localhost:8000/songs/Baby/update"

试试这个: <input type="hidden" name="_method" value="PUT">Route::put('songs/Baby/update','SongsController@update')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM