Skip to content

Commit

Permalink
MDL-37459 admin: Fix for error on updating a locked checkbox
Browse files Browse the repository at this point in the history
Changed the way apply_admin_locked_flags gets the current value for the field.

The old way was plain wrong (looking at getValue from the quickform element).
  • Loading branch information
Damyon Wiese authored and marinaglancy committed Jun 13, 2013
1 parent 19c1e0b commit 5410694
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ protected function apply_admin_locked_flags() {
$lockedicon = html_writer::tag('span',
$OUTPUT->pix_icon('t/locked', get_string('locked', 'admin')),
array('class' => 'action-icon'));
$isupdate = !empty($this->_cm);

foreach ($settings as $name => $value) {
if (strpos('_', $name) !== false) {
Expand All @@ -902,8 +903,12 @@ protected function apply_admin_locked_flags() {
$element = $mform->getElement($name);
$lockedsetting = $name . '_locked';
if (!empty($settings->$lockedsetting)) {
$value = $mform->getElement($name)->getValue();
$value = reset($value);
// Always lock locked settings for new modules,
// for updates, only lock them if the current value is the same as the default (or there is no current value).
$value = $settings->$name;
if ($isupdate && isset($this->current->$name)) {
$value = $this->current->$name;
}
if ($value == $settings->$name) {
$mform->setConstant($name, $settings->$name);
$element->setLabel($element->getLabel() . $lockedicon);
Expand Down

0 comments on commit 5410694

Please sign in to comment.