Jul 2, 2021
7
Level 2
old value checkbox
hello friends, i have form edit user .In this form i have checkbox to identify the old value role of user. i need to recover the old role of user . but it steel check the last role. this is the code of checkbox :
<div class="px-4 py-5 bg-white sm:p-6 ">
<x-jet-label for="role_id" class="text-1xl" value="{{ __('Roles :') }}" />
@foreach($roles as $id => $role)
<div><input type="radio" id="Role" name="role_id" value="{{ $role->id }}" checked >
{{ $role->name }}</div>
@endforeach
</div>
Level 122
How you could use role in this case
<input type="radio" name="role_id" value="{{ $role->id }}"
if(old('role_id', $user->role_id) == $role->id) checked @endif>
but I have had to guess here. The second parameter of the old() helper is the default value, so is probably the user's role, but you will have to adapt this to suit whatever it is you are editing
1 like
Please or to participate in this conversation.