Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill radio button with data coming from database Laravel Blade

So I am now working with the update part of my program, now i want to populate my forms with the older records from my database to edit it. Now my problem is the radio button, how can select the true one. I tried this code, i use if on my radio buttons

    {{ Form::label('Type','Type')}}    
    {{ Form::radio('ctype', '1',if(($item->bname)==1){true}) }}
    {{ Form::label('Rooster','Rooster')}}    
    {{ Form::radio('ctype', '0') }}
    {{ Form::label('Hen','Hen')}}    

But I just get error 500, please help

like image 478
jake balba Avatar asked Dec 20 '22 08:12

jake balba


1 Answers

In the documentation it says:

echo Form::radio('name', 'value', true);

So you should go this way:

{{ Form::radio('ctype', '1', $item->bname == 1) }}

You shouldn't need any additional brackets. Third param is a simple boolean value.

like image 154
MaGnetas Avatar answered Dec 21 '22 20:12

MaGnetas