Skip to content

Commit

Permalink
Merge branch 'MDL-74144-311' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_311_STABLE
  • Loading branch information
ilyatregubov committed Mar 16, 2022
2 parents 820cac7 + 767d46b commit 22fb553
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion user/amd/build/private_files.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion user/amd/build/private_files.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions user/amd/src/private_files.js
Expand Up @@ -33,13 +33,17 @@ import {add as addToast} from 'core/toast';
*/
export const initDynamicForm = (containerSelector, formClass) => {
const form = new DynamicForm(document.querySelector(containerSelector), formClass);

// When form is saved, refresh it to remove validation errors, if any:
form.addEventListener(form.events.FORM_SUBMITTED, () => {
form.load();
getString('changessaved')
.then(addToast)
.catch(null);
});

// Reload the page on cancel.
form.addEventListener(form.events.CANCEL_BUTTON_PRESSED, () => window.location.reload());
};

/**
Expand Down
4 changes: 3 additions & 1 deletion user/classes/form/private_files.php
Expand Up @@ -60,8 +60,10 @@ public function definition() {
}
$mform->setType('returnurl', PARAM_LOCALURL);

// The 'nosubmit' param (default false) determines whether we should show the standard form action buttons (save/cancel).
// This value is set when the form is displayed within a modal, which adds the action buttons itself.
if (!$this->optional_param('nosubmit', false, PARAM_BOOL)) {
$this->add_action_buttons(false, get_string('savechanges'));
$this->add_action_buttons();
}
}

Expand Down

0 comments on commit 22fb553

Please sign in to comment.