问题描述
当我点击表单提交按钮页面时,页面重定向到 addshortlist 功能。显示未定义偏移量的函数:0(视图:path\profile.blade.PHP)错误。在我的表格下方
<form action="addshortlist" id="addshortlist" method="PUT">
{{ csrf_field() }}
<input type="hidden" name="shortlistid" value="{{$data[0]->id}}">
<button type="submit" class="btn btn-primary">Add Shortlist</button>
</form>
我的路由功能是
Route::post('addshortlist','UserController@addshortlist');
功能类似
function addshortlist()
{
//
}
解决方法
您是否包含 $data 数组以查看由 addshortlist()
函数返回的视图?
喜欢
public function addShortList() {
return view('profile')->with('data',$someDataArray);
}
或
public function addShortList() {
return view('profile',compact($someDataArray);
}