0

i have a problem where a checked checkbox is not displaying checked.

My view:

@if(in_array($searchgroup->id.','.$searchtag->id, session()->get('zoektermen')))
    {{ Form::checkbox($searchtag->naam,$searchgroup->id. ',' .$searchtag->id, true, ['class' => 'search-checkbox']) }} {{ $searchtag->naam }}
@else
    {{ Form::checkbox($searchtag->naam,$searchgroup->id. ',' .$searchtag->id, null,['class' => 'search-checkbox']) }} {{ $searchtag->naam }}
@endif

I'm using laravel collective.

I'm using this code on other places on the website in different scenario's, where this works perfectly and the checkboxes display checked.

I'm using firefox but i also tried safari, no difference. enter image description here

Any help is appreciated..

Rubberduck1337106092
  • 1,044
  • 2
  • 19
  • 34
  • 2
    *How many checks could a checkbox check if a checkbox could check checks?* ... sorry. – CD001 Jun 27 '17 at 10:11
  • What's with the random error suppression on the conditionals? Is there any Javascript that's monkeying about with checkboxes that have the class `search-checkbox` (or similar)? – CD001 Jun 27 '17 at 10:12
  • Its may be theme/template issue. Its not an issue of Laravel. Because in your screenshot its rendered as `checked = "checked"` – B. Desai Jun 27 '17 at 10:15
  • @CD001 hahaha, but no no javascript interfering with the checkboxes – Rubberduck1337106092 Jun 27 '17 at 10:15
  • @B.Desai Yes, but i use the almost the same code, to populate a checked checkbox on another page and that is working fine... – Rubberduck1337106092 Jun 27 '17 at 10:17
  • remove class from input ... try... if it works then the problem in css... – Ashu Jun 27 '17 at 10:20
  • I noticed yesterday when I updated from Laravel 5.2 to 5.3, that even when not binding to a model with Form::, if you are passing 2 arrays to the templates, it appears like one of the arrays will "bind" if both arrays contain the same property name, in this case, is it possible that $searchgroup->id is overriding $searchtag->id? No clue why/what they changed, it appears like some scoping issue/bug after Laravel 5.2. – Mfoo Jun 27 '17 at 10:26
  • @pAsh No change when i remove class – Rubberduck1337106092 Jun 27 '17 at 11:10

2 Answers2

0

Consider the example having checked checkbox or not depending on the say user status Active or Inactive

{!! Form::checkbox('status', 'Active',  ($userData->status == 'Active') ? 'checked="checked"' : '' ,['data-prompt-position' => 'centerRight','data-title'=>'Active']) !!}
Rupali Pemare
  • 508
  • 1
  • 9
  • 24
0

If you have included "uniform.default.js" in your project, it can create such an issue. Please use the following code to resolve it.

$('#checkbox').prop('checked',true).uniform('refresh');

Further reading: jQuery Uniform Checkbox does not (un)check

Thanks.

Roger Jacob
  • 270
  • 3
  • 11