laravel 5.2 如何在编辑 table 期间将旧值放入 Form::select 及其关系

laravel 5.2 how to put the old value in Form::select during edit table with it's relation

我为 matches.I 开发了一个网站,有 table 联赛和 table 统计数据。table 联赛与统计数据有一对多关系 table .

在页面统计中我有 Form::select

这是代码

<div class="form-group">
                  <label for="name" class="col-md-3 control-label"><br> هذه الاحصائيه</label>
             <div class="col-md-9">
               {{ Form::select("toLeague", $leagues, null, ['class' => 'form-control']) }}


               </div>
                </div>

**** 用户将 select 联赛用于统计,当我编辑统计时我想要联赛的旧值 Form::select****

如何在表单 select 中执行此操作? 请任何人帮助我

您可以使用 Form-model 绑定来实现。

Form::model($statistic, ['route' => ['.......']])

它将自动 select 您存储的值匹配字段名称与表单输入名称。

在这里你会有所了解。

https://laravelcollective.com/docs/5.3/html#form-model-binding

还有一个办法。考虑到您的外键名称在统计信息中是 leage_id table 更新您的表单如下:

{{ Form::select("toLeague", $leagues, $statistic->league_id, ['class' => 'form-control']) }}