我正在尝试编辑和保存一些文章,但收到此错误:Creating default object from empty value
。我的代码有什么问题?因为在编辑时我有subject
,但是提交后会出现此错误。
我的错误: https://imgur.com/a/eWGqc5B
控制器
public function update($type, $id)
{
/* print_r(Input::all()); die; */
if($type == "News")
{
$article = \App\News::find($id);
$article->subject = Request::input('subject');
$article->public = Request::input('public');
$article->category_id = Request::input('category_id');
$article->information = Request::input('information');
$article->update();
}
if($type == "Event")
{
$article = \App\Event::find($id);
$article->subject = Request::input('subject');
$comm->comments = Request::input('comments');
$article->public = Request::input('public');
$article->category_id = Request::input('category_id');
$article->event_type_id = Request::input('event_type_id');
$article->country = Request::input('country');
$article->starts = Request::input('starts');
$article->ends = Request::input('ends');
$article->organizer = Request::input('organizer');
$article->address = Request::input('address');
$article->city = Request::input('city');
$article->website = Request::input('website');
$article->email = Request::input('email');
$article->telephone = Request::input('telephone');
$article->information = Request::input('information');
$article->update();
}
return redirect(URL::previous());
ArticleController.php中的669行
$article->subject = Request::input('subject');
这是我的 editEvent 代码:https://codepen.io/anon/pen/YodwKO
我的 articles.blade 代码:https://codepen.io/anon/pen/jjXWOb
我的路线: ` 路线:: post('admin / article / update / {type?} / {id?}',['as'=>'update.article','uses'=>'ArticleController @ update']); >
`
答案 0 :(得分:1)
未定义变量$ comm。看起来像错字。