Check if item is set before trying to look up selected

This commit is contained in:
snipe 2017-12-01 16:49:51 -08:00
parent 5a3233da37
commit c220315cb0

View file

@ -3,9 +3,9 @@
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} {{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
<div class="col-md-7 required"> <div class="col-md-7{{ ((isset($required)) && ($required=='true')) ? ' required' : '' }}">
<select class="js-data-ajax" data-endpoint="manufacturers" name="{{ $fieldname }}" style="width: 100%" id="category_select_id"> <select class="js-data-ajax" data-endpoint="manufacturers" name="{{ $fieldname }}" style="width: 100%" id="category_select_id">
@if ($manufacturer_id = Input::old($fieldname, $item->{$fieldname})) @if ($manufacturer_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
<option value="{{ $manufacturer_id }}" selected="selected"> <option value="{{ $manufacturer_id }}" selected="selected">
{{ (\App\Models\Manufacturer::find($manufacturer_id)) ? \App\Models\Manufacturer::find($manufacturer_id)->name : '' }} {{ (\App\Models\Manufacturer::find($manufacturer_id)) ? \App\Models\Manufacturer::find($manufacturer_id)->name : '' }}
</option> </option>