MDL-75337 core: Single button - core changes
* Change all core calls toward single_button to use single_button::BUTTON_PRIMARY
when needed
This commit is contained in:
+14
-8
@@ -2051,12 +2051,16 @@ class core_renderer extends renderer_base {
|
||||
$displayoptions['cancelstr'] = $displayoptions['cancelstr'] ?? get_string('cancel');
|
||||
|
||||
if ($continue instanceof single_button) {
|
||||
// ok
|
||||
$continue->primary = true;
|
||||
// Continue button should be primary if set to secondary type as it is the fefault.
|
||||
if ($continue->type === single_button::BUTTON_SECONDARY) {
|
||||
$continue->type = single_button::BUTTON_PRIMARY;
|
||||
}
|
||||
} else if (is_string($continue)) {
|
||||
$continue = new single_button(new moodle_url($continue), $displayoptions['continuestr'], 'post', true);
|
||||
$continue = new single_button(new moodle_url($continue), $displayoptions['continuestr'], 'post',
|
||||
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
|
||||
} else if ($continue instanceof moodle_url) {
|
||||
$continue = new single_button($continue, $displayoptions['continuestr'], 'post', true);
|
||||
$continue = new single_button($continue, $displayoptions['continuestr'], 'post',
|
||||
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
|
||||
} else {
|
||||
throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL (string/moodle_url) or a single_button instance.');
|
||||
}
|
||||
@@ -3120,7 +3124,7 @@ EOD;
|
||||
if (!($url instanceof moodle_url)) {
|
||||
$url = new moodle_url($url);
|
||||
}
|
||||
$button = new single_button($url, get_string('continue'), 'get', true);
|
||||
$button = new single_button($url, get_string('continue'), 'get', single_button::BUTTON_PRIMARY);
|
||||
$button->class = 'continuebutton';
|
||||
|
||||
return $this->render($button);
|
||||
@@ -5567,11 +5571,13 @@ class core_renderer_maintenance extends core_renderer {
|
||||
// We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be
|
||||
// from any previous version of Moodle).
|
||||
if ($continue instanceof single_button) {
|
||||
$continue->primary = true;
|
||||
$continue->type = single_button::BUTTON_PRIMARY;
|
||||
} else if (is_string($continue)) {
|
||||
$continue = new single_button(new moodle_url($continue), get_string('continue'), 'post', true);
|
||||
$continue = new single_button(new moodle_url($continue), get_string('continue'), 'post',
|
||||
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
|
||||
} else if ($continue instanceof moodle_url) {
|
||||
$continue = new single_button($continue, get_string('continue'), 'post', true);
|
||||
$continue = new single_button($continue, get_string('continue'), 'post',
|
||||
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
|
||||
} else {
|
||||
throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL' .
|
||||
' (string/moodle_url) or a single_button instance.');
|
||||
|
||||
Reference in New Issue
Block a user