I have a problem with some checkboxes. They are always checked, except if I put "false" in all of them. I have a function returnig if an "id" is in a array, it works fine. But either it return true or false checkboxes still checked. This is my function:
public function hasTipologia($id){
$array = $this->tipologias->lists('id');
MyHelpers::debugArray([$array,$id,in_array($id,$array)],false);
return in_array($id,$array);
}
MyHelpers show me for debuging the array of ids, the current id of "Tipologia" and if it's in the array or not.
Here you can see that it works
And the code in my View is:
@if(count($tipologias))
<h4>Tipologías estratégicas</h4>
<div class="col-md-12">
@foreach($tipologias as $tipologia)
<div class="col-md-3">
{{ Form::checkbox('tipologias[]',$tipologia->id,$formacion->hasTipologia($tipologia->id)===true ?true:false , ['class' => 'form-control']) }}
{{$tipologia->nombre}}
</div>
@endforeach
</div>
@endif
I try with different codes, and if I put this one:
$formacion->hasTipologia($tipologia->id)===true ?false:false
Still checked, and with this one the same:
$formacion->hasTipologia($tipologia->id)===false ?true:false
I have make and @if an then insert two forms, one with true and one with false, and still checked.
Any idea? Thanks ;)
Aucun commentaire:
Enregistrer un commentaire