Reputation: 492
Im currently in the process of learning Laravel 4.
I'm trying to create a really simple post form, here is my code for the opening of the form:
{{ Form::open(array('post' => 'NewQuoteController@quote')) }}
And then within my NewQuoteController i have the following:
public function quote() {
$name = Input::post('ent_mileage');
return $name;
}
I keep getting the following error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
It's probably something really stupid... Thanks.
EDIT
This is what I have in my routes.php
Route::get('/newquote','NewQuoteController@vehicledetails');
Route::post('/newquote/quote', 'NewQuoteController@quote');
Upvotes: 3
Views: 18911
Reputation: 87719
For POST looks like you need to change it to:
{{ Form::open(array('action' => 'NewQuoteController@quote')) }}
And you need to have a route to your controller action:
Route::post('quote', 'NewQuoteController@quote');
Default method for Form::open()
is POST, but if you need to change it to PUT, for example, you will have to
{{ Form::open(array('method' => 'PUT', 'action' => 'NewQuoteController@quote')) }}
And you'll have to create a new route for it too:
Route::put('quote', 'NewQuoteController@quote');
You also have to chage
$name = Input::post('ent_mileage');
to
$name = Input::get('ent_mileage');
You can use the same url for the different methods and actions:
Route::get('/newquote','NewQuoteController@vehicledetails');
Route::post('/newquote', 'NewQuoteController@quote');
Route::put('/newquote', 'NewQuoteController@quoteUpdate');
Upvotes: 9
Reputation: 11
Have you tried changing your form open to
{{Form::open(['method'=>'POST', 'route' =>'NewQuoteController@quote')}}
and in your controller access the form input using one of the Input methods ?
public function quote() {
$name = Input::get('ent_mileage');
return $name;
}
Upvotes: 1