Laravel Forms - Undefined

I use laravel to create a simple form:

    {{ Form::open(array('route' => 'postrequest')) }}
    {{ Form::text('Name') }}
    {{ Form::text('Surname') }}         
    {{ Form::submit('submit') }}
    {{ Form::close() }}

My route.php file shows the route:

Route::post('postrequest', function() 
{   
    return View::make('home');
});

But I get an error in the log file:

The following "ErrorException" exception with the message "Route [postrequest] is undefined.

I could not find a solution on the Internet. What am I doing wrong?

+4
source share
3 answers

You are trying to use the specified route here. If you want to do this, you need to change the route:

Route::post('postrequest', array('as' => 'postrequest', function() 
{   
    return View::make('home');
}));

or you can, of course, change the way a form is opened using a direct URL:

{{ Form::open(array('url' => 'postrequest')) }}

But you really have to use named routes .

+1

{{ Form::open(array('url' => 'postrequest', 'method' => 'post')) }}

.

+1

, - :

Route::post('postrequest', ['as' => 'postrequest', 'uses' => 'RequestController@store']);
+1

All Articles