MDL-80180 admin: added readonly support for multicheckbox

This commit is contained in:
Jeremy Schulz 2023-11-20 15:33:24 +01:00 committed by Jeremy Byron Schulz
parent 94ad185d09
commit a272c2289f
No known key found for this signature in database
GPG Key ID: 8EAFA97692BE4A58
2 changed files with 6 additions and 2 deletions

View File

@ -23,12 +23,15 @@
* name - form element name
* hasoptions - there are some options
* options - list of options containing name, key, id, checked, label
* readonly - bool
Example context (json):
{
"name": "test",
"hasoptions": true,
"options": [ { "name": "Option", "key": "k1", "id": "id0", "checked": true, "label": "Option label"} ]
"options": [ { "name": "Option", "key": "k1", "id": "id0", "checked": true, "label": "Option label"} ],
"readonly": false
}
}}
<div class="form-multicheckbox">
@ -37,7 +40,7 @@
<ul>
{{#options}}
<li>
<input type="checkbox" name="{{name}}[{{key}}]" value="1" id="{{id}}_{{key}}" {{#checked}}checked{{/checked}}>
<input type="checkbox" name="{{name}}[{{key}}]" value="1" id="{{id}}_{{key}}" {{#readonly}}disabled{{/readonly}} {{#checked}}checked{{/checked}}>
<label for="{{id}}_{{key}}">{{{label}}}</label>
</li>
{{/options}}

View File

@ -3265,6 +3265,7 @@ class admin_setting_configmulticheckbox extends admin_setting {
$context = (object) [
'id' => $this->get_id(),
'name' => $this->get_full_name(),
'readonly' => $this->is_readonly(),
];
$options = array();