表格:
{{ Form::open(array('url' => 'user/create', 'files' => true)) }}路由:
Route::resource('user', 'UserController');UserController.php
class UserController extends BaseController {
public function index()
{
return 'hi11';
//return View::make('home.index');
}
public function create()
{
return 'hi22';
//return View::make('home.index');
}
}这段代码给出了
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
发布于 2013-11-24 14:12:07
我只想沿着这些路线添加我自己的发现...也许这会省去我刚才做的那些令人头疼的事情。
我也实现了Route::resource机制。我不知道为什么我的create可以工作,但我的更新却不能。事实证明,您不能完全重用相同的表单代码,执行更新的表单必须使用PUT或PATCH方法。为什么更新不能成为一篇文章,我无法理解。
也就是说,更新的开始表单标记必须如下所示:
Form::model($thing, array(
'method' => 'PUT',
'route' => array('things.update', $thing->id)
)如果不指定方法=> PUT,就会得到这个无用的错误。
发布于 2013-07-19 20:22:02
因为在路由中使用资源控制器,所以只能使用文档http://laravel.com/docs/controllers#resource-controllers中所述的特定路径和操作。
user/create ( UserController::create )是您需要显示用于添加新用户的表单的位置。
用户的实际存储应该在user/store中完成,即您的表单必须是send data to UserController::store()方法。
在您的例子中,如果您只将表单发送给'url‘=> 'user',这应该会自动将数据发送到正确的方法。
发布于 2013-07-07 10:52:35
Laravel 4 resources have named routes -只需使用这些:
{{ Form::open(array('route' => 'user.create', 'files' => true)) }}https://stackoverflow.com/questions/17501653
复制相似问题