Skip to content

Commit

Permalink
MDLE-82214 admin: Settings should not change when in read only mode
Browse files Browse the repository at this point in the history
Before this change if some settings were:

* read only
* visible on a settings page
* are set or have values selected

when the settings page was saved the setting would be set tobe empty,
because the hidden input remained on the page, while the other inputs
where not posted to Moodle.
  • Loading branch information
NeillM committed Jun 18, 2024
1 parent fbed803 commit fd1bdae
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion admin/templates/setting_configcheckbox.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
}
}}
<div class="form-checkbox defaultsnext">
<input type="hidden" name="{{name}}" value="{{no}}">
{{^readonly}}<input type="hidden" name="{{name}}" value="{{no}}">{{/readonly}}
<input {{#readonly}}disabled{{/readonly}} type="checkbox" name="{{name}}" value="{{value}}" id="{{id}}" {{#checked}}checked{{/checked}}>
</div>
2 changes: 1 addition & 1 deletion admin/templates/setting_configmulticheckbox.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
}}
<div class="form-multicheckbox">
<input type="hidden" name="{{name}}[xxxxx]" value="1">
{{^readonly}}<input type="hidden" name="{{name}}[xxxxx]" value="1">{{/readonly}}
{{#hasoptions}}
<ul>
{{#options}}
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/setting_configmultiselect.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Setting configmultiselect.
}}
<div class="form-select">
<input type="hidden" name="{{name}}[xxxxx]" value="1">
{{^readonly}}<input type="hidden" name="{{name}}[xxxxx]" value="1">{{/readonly}}
<select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Setting configmultiselect with optgroup support.
}}
<div class="form-select">
<input type="hidden" name="{{name}}[xxxxx]" value="1">
{{^readonly}}<input type="hidden" name="{{name}}[xxxxx]" value="1">{{/readonly}}
<select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand Down

0 comments on commit fd1bdae

Please sign in to comment.