Reputation: 1255
I am using laravel to create simple form:
{{ Form::open(array('route' => 'postrequest')) }}
{{ Form::text('Name') }}
{{ Form::text('Surname') }}
{{ Form::submit('submit') }}
{{ Form::close() }}
In my routes.php file is defined route:
Route::post('postrequest', function()
{
return View::make('home');
});
But I'm getting error in log file:
Next exception 'ErrorException' with message 'Route [postrequest] not defined.
I couldnt find solution on internet. What I'm doing wrong?
Upvotes: 6
Views: 17648
Reputation: 9530
In case you want to reference a controller method in you route, you have to do something like this:
Route::post('postrequest', ['as' => 'postrequest', 'uses' => 'RequestController@store']);
Upvotes: 1
Reputation: 111839
You try to use here named route. If you want to do so you need to change your route into:
Route::post('postrequest', array('as' => 'postrequest', function()
{
return View::make('home');
}));
or you can of course change the way you open your form using direct url:
{{ Form::open(array('url' => 'postrequest')) }}
But you should really consider using named routes.
Upvotes: 2
Reputation: 5596
Open form with post method
{{ Form::open(array('url' => 'postrequest', 'method' => 'post')) }}
Since you have written Route for post request.
Upvotes: 2