I have a form where the user can activate or deactivate certain options with or without a checkbox
.
<input name="ppra" type="checkbox" data-oFF-text="INATIVO" value="1"
data-off-color="danger" data-size="small" data-on-text="ATIVO"
data-on-color="success" {{ $cliente->ppra == 'ativo' ? 'checked' : '' }}
onchange="checkStat(this, 'check-ppra');" id="check-ppra">
I created a function so that when a checkbox
is marked its value
becomes "active" and when it is unchecked becomes "inactive" .
function checkStat(input, name) {
if(input.checked == true){
$("#"+name).val('ativo');
}else{
$("#"+name).val('inativo');
}
}
But I noticed that when checkbox
is unchecked it just is not sent in request
, it sends ppp , pcmso and ignores ppra that was inactive.
I have already checked and seen that the function that assigns value
to active or inactive works correctly.
In my controller
I do not specify all the fields, I simply get everything and create the registry.
$this->repository->update($request->all(), $id);
How can I resolve this?