Fix restore defaults for radio buttons

Fix restore defaults for radio buttons
This commit is contained in:
stevenA 2021-12-31 12:45:12 +01:00
parent 10a0ddb123
commit 8268bbf81a
2 changed files with 14 additions and 8 deletions

View file

@ -1197,17 +1197,22 @@ $(".sccp-restore").click(function() {
return;
}
if ($(this).is(":checked")) {
console.log('restore/checked');
edit_style.display = 'block';
var defaultVal = $(this).data("default");
if ($(this).data("type") === 'radio') {
// simulate read only for checkboxes
input.forEach(
function(radioElement) {
radioElement.setAttribute('disabled', true);
if (radioElement.hasAttribute('checked')) {
radioElement.removeAttribute('disabled');
}
}
console.log(input);
input.forEach(
function(radioElement) {
radioElement.setAttribute('disabled', true);
if (radioElement.value === defaultVal){
radioElement.removeAttribute('disabled');
radioElement.setAttribute('checked', true);
} else {
radioElement.setAttribute('disabled', true);
radioElement.removeAttribute('checked');
}
}
);
return;
}

View file

@ -398,6 +398,7 @@ class formcreate
// reverting to chan-sccp default values
echo " data-for={$res_id}";
echo " data-type=radio";
echo " data-default={$sccp_defaults[$res_n]['systemdefault']}";
echo " class=sccp-restore";
echo " id=usedefault_{$res_id}";
echo " ";