3

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');

2 Answers 2

9

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');
Sign up to request clarification or add additional context in comments.

13 Comments

Still getting the same, I forgot to add i get this message when I submit the form...
With the route you're also getting this error? Check the HTML generated. Get the <FORM> line and pastebin it, or edit your message.
NotFoundHttpException is a route not found error. So your open() must be generating a route different from those you have. Could you paste your HTML <FORM> line?
<form method="POST" action="localhost:8888/l4_site/public/newquote/quote" accept-charset="UTF-8"><input name="_method" type="hidden" value="PUT"><input name="_token" type="hidden" value="ej7Wk63SHHM2OWyzqo6o6dz5E8rI5cBVckZdPjcc">
PUT? Are you doing POST or PUT?
|
1

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; 
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.