使用Laravel';s列表不起作用


Updating record in Laravel from a select using laravel's lists not working

在我的一个laravel页面中,我正在更新一条记录。表单被绑定到模型,所有字段都在正确更新,除了那些我使用从数据库中填充选择的列表来显示选择的字段:

{{ Form::select('resume_id', $resume_lists) }}

我只是不知道为什么这些不会更新。他们正在从mySQL中提取适当的值。有什么想法吗?

谢谢。

我的代码在路线中,而不是在控制器中

Route::get('application/edit/{id}', array('as' => 'application.edit',    function($id) 
{
    $user = Auth::user();
    $company_lists = Company::where('user_id', '=', $user->id)->get()->lists('company', 'id');
    $resume_lists = Resume::where('user_id', '=', $user->id)->get()->lists('name', 'id');   //changed resume to name
    $companies = Company::where('user_id', '=', Auth::user()->id)->get(); //just added
    //$currentintdate=$application['followupBy'];  /////
    Session::put('appid', $id); /////
    return View::make('application-edit', array('company_lists' => $company_lists), array('resume_lists' => $resume_lists)) 
        ->with('application', Application::find($id));
}));

试试这个:

$resume_lists = YourResumeModel::lists('title', 'id');
{{ Form::select('resume_id', $resume_lists) }}

第一列是下拉列表中的文本下一列是您的行id

只需var转储控制器中的恢复列表数据,确保其在控制器中可用,因此在初始化变量/数组后

return var_dump($resume_lists); // check if its valid array with id as key and label as value, if available, go view and do the same

使用:$resume_lists = Resume::all()->where('user_id', '=', $user->id)->lists('name', 'id');

或者:$resume_lists = Resume::where('user_id', '=', $user->id)->lists('name', 'id')->toArray();

好吧,我的记录没有更新,因为我有一列不可为null,并且在测试时没有传递任何值。我对此没有任何错误,所以我不知道。