我目前正在学习Laravel 4。
我正在尝试创建一个非常简单的帖子表单,下面是我打开表单的代码:
{{ Form::open(array('post' => 'NewQuoteController@quote')) }}
然后在我的NewQuoteController中,我有以下内容:
public function quote() {
$name = Input::post('ent_mileage');
return $name;
}
我一直得到以下错误:
Symfony''Component''HttpKernel''Exception''NotFoundHttpException
这可能真的很愚蠢。。。谢谢
编辑
这就是我的routes.php
Route::get('/newquote','NewQuoteController@vehicledetails');
Route::post('/newquote/quote', 'NewQuoteController@quote');
对于POST,您需要将其更改为:
{{ Form::open(array('action' => 'NewQuoteController@quote')) }}
你需要有一条通往控制器动作的路线:
Route::post('quote', 'NewQuoteController@quote');
Form::open()
的默认方法是POST,但如果您需要将其更改为PUT,例如,您将不得不使用
{{ Form::open(array('method' => 'PUT', 'action' => 'NewQuoteController@quote')) }}
你也必须为它创建一条新的路线:
Route::put('quote', 'NewQuoteController@quote');
您还必须更改
$name = Input::post('ent_mileage');
至
$name = Input::get('ent_mileage');
您可以对不同的方法和操作使用相同的url:
Route::get('/newquote','NewQuoteController@vehicledetails');
Route::post('/newquote', 'NewQuoteController@quote');
Route::put('/newquote', 'NewQuoteController@quoteUpdate');
您是否尝试过将表单更改为
{{Form::open(['method'=>'POST', 'route' =>'NewQuoteController@quote')}}
并且在您的控制器中使用其中一种输入方法访问表单输入?
public function quote() {
$name = Input::get('ent_mileage');
return $name;
}