问题
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