Mark a radio button according to the value of the database

0

In a form I have a cycle that generates 3 radiobuttons and assigns the Id and the name they have in the database

@foreach($type as $t)
            <div class="custom-control custom-radio">
                {{Form::radio('incapacityType',$t->id)}}
                {{Form::label('incapacityType',$t->name)}}
            </div>
            @endforeach

To edit a record how can I mark a radio button according to the corresponding value in the database Example. If in the record the 1st radiobutton (value = 1) was selected when editing that record, you must select that same radio button

    
asked by gmrYaeL 04.12.2018 в 22:21
source

1 answer

1

Solved validate if the result of the database is equal to the value of the radio button if so mark it if it follows the next ($ t-> id == $ regiter-> gregType-> id? true: false)

@foreach($type as $t)
            <div class="custom-control custom-radio">
                {{Form::radio('incapacityType',$t->id,$t->id == $absence->absType->id ? true : false)}}
                {{Form::label('incapacityType',$t->name)}}
            </div>
            @endforeach
    
answered by 04.12.2018 / 22:48
source