Adding form action in html in laravel

前端 未结 12 1300
深忆病人
深忆病人 2020-12-29 21:10

I am unable to pass url in views html form action tag.

12条回答
  •  不知归路
    2020-12-29 21:41

    I wanted to store a post in my application, so I created a controller of posts (PostsController) with the resources included:

    php artisan make:controller PostsController --resource

    The controller was created with all the methods needed to do a CRUD app, then I added the following code to the web.php in the routes folder :

    Route::resource('posts', 'PostsController');

    I solved the form action problem by doing this:

    1. I checked my routing list by doing php artisan route:list
    2. I searched for the route name of the store method in the result table in the terminal and I found it under the name of posts.store
    3. I added this to the action attribute of my form: action="{{route('posts.store')}}" instead of action="??what to write here??"

提交回复
热议问题