laravel-bootstrap-4-forms icon indicating copy to clipboard operation
laravel-bootstrap-4-forms copied to clipboard

checkboxes don't get checked.

Open nepp95 opened this issue 5 years ago • 3 comments

Hello,

While filling the form with eloquent data doesn't work for checkboxes. It isn't actually possible to set the checked state.

Reproduction: Using bootstrap from npm with: "bootstrap": "^4.0.0",

Using this package through composer: "netojose/laravel-bootstrap-4-forms": "^3.0"

Tried:

{!! Form::checkbox('post_is_equal', __('site.customer.post_is_equal'), 1, true) !!}
{!! Form::checkbox('post_is_equal', __('site.customer.post_is_equal'), 'on', true) !!}
{!! Form::checkbox('post_is_equal', __('site.customer.post_is_equal'), '1', true) !!}
{!! Form::checkbox('post_is_equal', __('site.customer.post_is_equal'))->checked() !!}
{!! Form::checkbox('post_is_equal', __('site.customer.post_is_equal'))->checked(true) !!}

All of the above result in an unchecked checkbox. Maybe some breaking change in bootstrap that renders this unusable?

nepp95 avatar Jan 22 '20 15:01 nepp95

Update. Only happens if the checkbox name (first parameter) is also a column name in the data you use to fill the form.

nepp95 avatar Jan 27 '20 09:01 nepp95

This bug still persists. I can confirm it is when you are using fill() and the name is one of the fields.

vilocity-brian avatar May 08 '20 21:05 vilocity-brian

I avoid the problem like this:

public function getMyCheckboxAttribute()
{
    return $this->attributes['my_checkbox'] ? 'on' : 'off';
}

koptelovav avatar May 01 '21 13:05 koptelovav