Form submits as GET Laravel 4

≯℡__Kan透↙ 提交于 2019-12-14 01:59:11

问题


I have form like this

<form action="{{ Request::root() }}/articles/update/" method="post">
    <input type="hidden" name="id" value="{{ $article->id }}" />
    <input type="submit" name="submit" value="Submit" />
</form>

And route like this

Route::post('articles/update', array('as' => 'articleUpdate', 'uses' => 'ArticlesController@update'));

But when I submit the form, I get MethodNotAllowedHttpException. In error report I can see that request method is GET. I have also tried using caps for method method="POST" but it didn't work.

Any ideas?


回答1:


What does FireBug/Web console inspector show you? is the form being sent via GET or POST, any redirects?

Seems a redirection problem to me, after reaching the server Laravel redirects to the URL the form sent the post request.




回答2:


you must use put method here. Form change like this

 {{Form::open(array('url'=>'/articles/update','method' => 'PUT'))}}

Routes like this

 Route::put('/articles/update','ArticlesController@update');


来源:https://stackoverflow.com/questions/17240767/form-submits-as-get-laravel-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!