Browse Source

trying to add dropdowns to edit blades - adjunctadditions mkI

master
jk 3 years ago
parent
commit
572e6e63ba
  1. 8
      app/Http/Controllers/AdjunctAdditionController.php
  2. 25
      resources/views/adjunctadditions/edit.blade.php

8
app/Http/Controllers/AdjunctAdditionController.php

@ -55,7 +55,13 @@ class AdjunctAdditionController extends Controller
}
public function edit($id){
$adjunctaddition = Adjunctaddition::where('id', (int)$id)->first();
return view('adjunctadditions.edit')->with('adjunctaddition', $adjunctaddition);
$beers = Summarie::orderBy('name')->get();
$selected_beer = $adjunctaddition->beer_id;
$adjuncts = Adjunct::orderBy('name')->get();
$selected_adjunct = $adjunctaddition->adjunct_id;
$selected_alt = $adjunctaddition->alternative;
$data = array('adjunctaddition'=>$adjunctaddition, 'beers'=>$beers, 'adjuncts'=>$adjuncts, 'selected_beer'=>$selected_beer, 'selected_adjunct'=>$selected_adjunct, 'selected_alt'=>$selected_alt);
return view('adjunctadditions.edit')->with($data);
}
public function update(Request $request, $id){

25
resources/views/adjunctadditions/edit.blade.php

@ -17,12 +17,20 @@
@method('PATCH')
@csrf
<div class="form-group">
<label for="beer_id">Beer ID</label>
<input type="text" class="form-control" name="beer_id" value="{{$adjunctaddition->beer_id}}" />
<label for="beer_id">Beer</label>
<select class="form-control" name="beer_id">
@foreach ($beers as $beer)
<option value="{{$beer->beer_id}}" {{ $selected_beer == $beer->beer_id ? 'selected="selected"' : '' }}>{{$beer->name}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="adjunct_id">Adjunct ID</label>
<input type="text" class="form-control" name="adjunct_id" value="{{$adjunctaddition->adjunct_id}}" />
<label for="adjunct_id">Adjunct</label>
<select class="form-control" name="adjunct_id">
@foreach ($adjuncts as $adjunct)
<option value="{{$adjunct->id}}" {{ $selected_adjunct == $adjunct->id ? 'selected="selected"' : '' }}>{{$adjunct->name}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="amount">Amount</label>
@ -33,8 +41,13 @@
<input type="text" maxlength="10" class="form-control" name="timing" value="{{$adjunctaddition->timing}}" />
</div>
<div class="form-group">
<label for="alternative">Alternative (ID)</label>
<input type="text" class="form-control" name="alternative" value="{{$adjunctaddition->alternative}}" />
<label for="alternative">Alternative</label>
<select class="form-control" name="alternative">
<option value="">None suggested</option>
@foreach ($adjuncts as $adjunct)
<option value="{{$adjunct->id}}" {{ $selected_alt == $adjunct->alternative ? 'selected="selected"' : '' }}>{{$adjunct->name}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="notes">Notes</label>

Loading…
Cancel
Save