使用不工作的laravel列表从选择中更新Laravel中的记录

时间:2015-11-27 19:37:48

标签: php laravel laravel-4

在我的一个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));
}));

4 个答案:

答案 0 :(得分:0)

试试这个:

{{1}}

frist列是您下拉列表的文本 下一栏是你的行ID

答案 1 :(得分:0)

只是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

答案 2 :(得分:0)

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

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

答案 3 :(得分:0)

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