MDL-87334 course: looser check for empty return field editing course.

When the course format switcher reloads the form, the `$returnto`
parameter is of type string: "0", rather of type integer per initial
load.

In this case the `empty(...)` check is verifying all of empty string,
0 (integer) and "0" (string). Hurrah for PHP type checking.
This commit is contained in:
Paul Holden
2026-01-30 10:37:55 +00:00
parent 59fd844136
commit fb3e6c2e8c
+1 -1
View File
@@ -429,7 +429,7 @@ class course_edit_form extends moodleform {
// When two elements we need a group.
$buttonarray = array();
$classarray = array('class' => 'form-submit');
if ($returnto !== 0) {
if (!empty($returnto)) {
$buttonarray[] = &$mform->createElement('submit', 'saveandreturn', get_string('savechangesandreturn'), $classarray);
}
$buttonarray[] = &$mform->createElement('submit', 'saveanddisplay', get_string('savechangesanddisplay'), $classarray);