Fill in the switch with data coming from the Laravel Blade database

So, now I am working with the update part of my program, now I want to fill out my forms with old entries from my database in order to edit them. Now my problem is the switch on how to choose the right 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'm just getting 500 error, please help

+4
source share
1 answer

The documentation says:

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

So you should go as follows:

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

You do not need any extra brackets. The third parameter is a simple Boolean value.

+10
source

All Articles