Support the ongoing development of Laravel.io →
Database Forms
Last updated 1 year ago.
0

Try this:

{{ Form::radio('tributary', 'true', $station->tributary }} Yes
Last updated 1 year ago.
0

franzliedke said:

Try this:

{{ Form::radio('tributary', 'true', $station->tributary }} Yes

Didn't work. Anyway it's strange, when tributary is false, both radio buttons (one for true value and another for false value) are unchecked but, when tributary is true, false radio button is checked.

Last updated 1 year ago.
0

Ok, I solved the issue, error was value of radio must be 1 or 0 (true and false didn't work for me) and not 'true' or 'false' (with '' are strings and not booleans). Now Form Modal Binding detects correctly the radio buttons.

{{ Form::radio('tributary', 1) }} Yes
{{ Form::radio('tributary', 0) }} No
Last updated 1 year ago.
0

I found this page when looking for a solution to marking 1 of many radio buttons as true depending on what was saved in the database. I figured out a solution shortly after and thought I would add my solution if anyone else finds this page as I did. You can't use if statements to set values for the different options, plus this method is faster I believe.

{{ Form::radio('name', 'value1', ($var->option == 'value1') }} Value1
{{ Form::radio('name', 'value2', ($var->option == 'value2') }} Value2
{{ Form::radio('name', 'value'3, ($var->option == 'value3') }} Value3

this results in giving only the stored value a 1 which makes that option/value active.

0

The title says 'Form Model Binding and Radio Buttons' but I don't see any form model binding here! I was expecting to find some way of populating several radio buttons using form model binding...

Last updated 8 years ago.
0

I agree. No Form Model Binding on that solution.

0

I fixed it by using a ['checked' => 'checked'] array as a fourth argument in Laravel 5.3

{{ Form::label('visible', 'Visibility') }}

            @if ($category->visible == '1')
                {{ Form::radio('visible', '1', true, ['checked' => 'checked']) }} Yes
                <br />
                {{ Form::radio('visible', '0', false, []) }} No
            @else
                {{ Form::radio('visible', '1', false, []) }} Yes
                <br />
                {{ Form::radio('visible', '0', true, ['checked' => 'checked']) }} No
            @endif

http://deepdivetuts.com/adding-a-radio-button-in-laravel-5-3-b...

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.