我很难让它正常工作,我试图将id变量传递给方法的方式可能有错误。我正在使用Laravel。
我的视图包含此表单来处理函数并传递id:
{{ Form::open(array('method' => 'GET', 'url' => array('uploads/edit', $upload->id))) }}
{{ Form::submit('Edit', array('class' => 'btn btn-info')) }}
{{ Form::close() }}
控制器:
public function getEdit($id)
{
$upload = $this->upload->find($id);
if (is_null($upload))
{
return Redirect::to('uploads/alluploads');
}
$layout->layout->content = View::make('uploads.edit', compact('upload'));
}
错误:
ErrorException
Creating default object from empty value
答案 0 :(得分:3)
错误在这里;
$layout->layout->content = ....
您无法做到这一点,因为您没有定义$ layout或$ layout->布局。尝试:
$layout = View::make('uploads.edit', compact('upload'));
或者如果你真的希望它与你现在的代码完全一样,你可以这样做;
$layout = new stdClass();
$layout->layout = new stdClass();
$layout->layout->content = View::make('uploads.edit', compact('upload'));