I have a database of Leagues and I need to have a drop down list inside a form of the different leagues...
I have got this working but the Option Value is displaying as the ID number and I need it to display as the league_name field...
Controller
public function getEdit($id = null)
{
try {
// Get the group information
$tip = Tips::find($id);
$league = Leagues::lists('league_name', 'id');
} catch (TipNotFoundException $e) {
// Redirect to the groups management page
return Redirect::route('tips')->with('error', Lang::get('tips/message.group_not_found', compact('id')));
}
// Show the page
return View('admin/tips/edit', compact('tip','league'));
}
View Blade
<div class="form-group">
<label for="league" class="col-sm-3 control-label">League</label>
<div class="col-sm-9">
{!! Form::select('league', $league, Input::old('league'), ['class' => 'form-control required', 'id' => 'league', 'placeholder' => 'Select League']) !!}
</div>
</div>
It is outputting as...
<select class="form-control required" id="league" name="league">
<option selected="selected" value="">Select League</option>
<option value="1">FIFA World Cup</option>
<option value="2">FIFA Women's World Cup</option>
<option value="3">FIFA Confederations Cup</option>
<option value="4">Summer Olympic Games (FIFA unofficial)</option>
I want it to output as...
<select class="form-control required" id="league" name="league">
<option selected="selected" value="">Select League</option>
<option value="FIFA World Cup">FIFA World Cup</option>
<option value="FIFA Women's World Cup">FIFA Women's World Cup</option>
<option value="FIFA Confederations Cup">FIFA Confederations Cup</option>
<option value="Summer Olympic Games (FIFA unofficial)">Summer Olympic Games (FIFA unofficial)</option>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire