Originally created by: gitsnow
For more information on how to write a good bug report
Custom Fields with checkboxes can't be unchecked. This issue occurs because both posting and serializing forms don't account for unchecked inputs.
Expected behavior: [What you expected to happen]
Field should be saved with the unchecked value
Actual behavior: [What actually happened]
Field is not updated and error pops up
osTicket 1.11.0
PHP 7.2.15
Ubuntu 18.04
I was able to create a workaround that checks unchecked checkboxes, but sets their values to 0. This works even though custom checkbox fields have their values set to their ID. I also hid the inputs before submission to avoid the user seeing all checkboxes as checked.
Change Line 702 from
function(e) { submit_button = $(this); });
to
function(e) { submit_button = $(this); uncheckedPrep(); });
Add this to bottom of scp/js/scp.js
function uncheckedPrep() {
$("form").submit(function () {
var form = $(this);
form.find('input[type="checkbox"]').each(function () {
var currentCheckbox = $(this);
currentCheckbox.hide();
if (currentCheckbox.is(':checked') == false) {
currentCheckbox.prop('checked', true);
currentCheckbox.attr('value', '0');
}
});
});
}
uncheckedPrep();
Originally posted by: JediKev
@gitsnow
I’ll try to reproduce this tomorrow. You shouldn’t have to add a whole new function, it’s most likely a bug or maybe something that needs updating to the new jQuery standards.
Cheers.
Originally posted by: gitsnow
@JediKev
I figured as much because this issue looks to have been fixed in past versions. I just provided my workaround until a more elegant solution could be put into place.
Thanks for the quick reply!