I am writing the logic for an edit form and have some complications when displaying data in the inputs.
When I initially show the form, I show the records values like:
I know this has already been answered but I thought I would leave a little snippet here for others in the future.
Setting old value on input as @ikurcubic posted can be used the same way on radio button or select:
Select option:
Radio Button:
default-value)== "M" ? 'checked' : '' }} />
Another way of doing it; write a small if statement to determine which value should be evaluated:
@php
if(old('name') !== null){
$option = old('name');
}
else{ $option = $database->value; }
@endphp
Setting old value of input with an array name e.g name="name[]":
This will give you the old value of the input with an index of 0.
I have tested this and it works.