Tom*_*ran 6 php forms routes exception laravel
我正在使用laravel来创建简单的表单:
{{ Form::open(array('route' => 'postrequest')) }}
{{ Form::text('Name') }}
{{ Form::text('Surname') }}
{{ Form::submit('submit') }}
{{ Form::close() }}
Run Code Online (Sandbox Code Playgroud)
在我的routes.php文件中定义了route:
Route::post('postrequest', function()
{
return View::make('home');
});
Run Code Online (Sandbox Code Playgroud)
但我在日志文件中收到错误:
下一个异常'ErrorException',消息'Route [postrequest]未定义.
我无法在互联网上找到解决方案.我做错了什么?
您尝试在此处使用命名路线。如果您想这样做,您需要将路线更改为:
Route::post('postrequest', array('as' => 'postrequest', function()
{
return View::make('home');
}));
Run Code Online (Sandbox Code Playgroud)
或者您当然可以使用直接网址更改打开表单的方式:
{{ Form::open(array('url' => 'postrequest')) }}
Run Code Online (Sandbox Code Playgroud)
但您确实应该考虑使用命名路由。
| 归档时间: |
|
| 查看次数: |
16420 次 |
| 最近记录: |