Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Collective Form checkbox always checked

I'm using Laravel Collective for Forms and having an issue with checkbox.

Here is what I'm doing :

{!! Form::checkbox('independent',null,['class'=>'form-control', 'required' => 'required'])!!}

I've tried changing values for "null", added one more parameters as suggested by many while googling for solution but nothing seems to be working.

If anyone know the solution or having same issue, please share.

like image 856
Praveen Dabral Avatar asked Dec 06 '25 15:12

Praveen Dabral


1 Answers

The documentation states that the third parameter is a boolean that determines if the checkbox is checked, you have an array as the third parameter. Php interprets an array as true, this is why your checkbox is always checked.

You should add true or false as the third parameter and add the options array as a fourth parameter. This can be found in the source code on GitHub.

{!! Form::checkbox('independent', null, false) !!}
like image 162
Jerodev Avatar answered Dec 09 '25 06:12

Jerodev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!