in my create function, I pass my view a list of users which I then display. However, I have changed it to the following
<select class="internalWork" name="internalWork">
<option value=""></option>
@foreach($users as $user)
<option value="{{ $user->userName }}">{{ $user->userName }}</option>
@endforeach
</select>
So I have added an empty option before the list is displayed. This is fine because this tables column allows null input.
In my edit function, I get the list
$users = User::lists('userName', 'userName');
I then pass this to my edit view. In my edit view, I have the following
<div class="form-group">
{!! Form::label('internalWork', 'Internal work for:', array('class' => 'col-sm-5 control-label red')) !!}
<div class="col-sm-7">
{!! Form::select('internalWork', $users, null, ['class' => 'internalWork']) !!}
</div>
</div>
If I selected a user in the create, then when I go to the edit page, that user is selected by default. However, if I do not select a user in the create, on the edit page, the first user in the list is displayed by default.
How can I get it to display an empty input if the database value is null?
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire