Skip to content

Commit

Permalink
MDL-65217 core_form: use uniqie element id in filepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin authored and marinaglancy committed Apr 29, 2019
1 parent 14cdf51 commit 54e067d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/form/filepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ M.form_filepicker.callback = function(params) {
html += '<div class="dndupload-progressbars"></div>';
M.form_filepicker.Y.one('#file_info_'+params['client_id'] + ' .filepicker-filename').setContent(html);
//When file is added then set status of global variable to true
var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;
M.form_filepicker.instances[elementname].fileadded = true;
var elementid = M.core_filepicker.instances[params['client_id']].options.elementid;
M.form_filepicker.instances[elementid].fileadded = true;
//generate event to indicate changes which will be used by disable if or validation code
M.form_filepicker.Y.one('#id_'+elementname).simulate('change');
M.form_filepicker.Y.one('#'+elementid).simulate('change');
};

/**
Expand All @@ -22,8 +22,8 @@ M.form_filepicker.init = function(Y, options) {
M.form_filepicker.Y = Y;

//For client side validation, initialize file status for this filepicker
M.form_filepicker.instances[options.elementname] = {};
M.form_filepicker.instances[options.elementname].fileadded = false;
M.form_filepicker.instances[options.elementid] = {};
M.form_filepicker.instances[options.elementid].fileadded = false;

//Set filepicker callback
options.formcallback = M.form_filepicker.callback;
Expand Down
2 changes: 1 addition & 1 deletion lib/form/filepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function toHtml() {
$args->maxbytes = $this->_options['maxbytes'];
$args->context = $PAGE->context;
$args->buttonname = $elname.'choose';
$args->elementname = $elname;
$args->elementid = $id;

$html = $this->_getTabs();
$fp = new file_picker($args);
Expand Down

0 comments on commit 54e067d

Please sign in to comment.