0

I developed a website for matches.I have table for leagues and table for statistics .table league has relation one to many with statistics table.

In page statistics I have Form::select

This is the code

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

****User will select league for statistic,when I edit the statistic I want the old value of the league in Form::select****

How to do this in form select? please any one help me

Azhar Nabil
  • 73
  • 11

1 Answers1

1

You can use Form-model binding to accomplish that.

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

It'll auto select your stored values matching field name with form input name.

Here you will get some idea.

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

Also there is another way. Consider your foreign key name is leage_id in statistics table update your form like below:

{{ Form::select("toLeague", $leagues, $statistic->league_id, ['class' => 'form-control']) }}
Mahfuzul Alam
  • 3,057
  • 14
  • 15