Skip to content

Commit

Permalink
MDL-37397 Test for a valid select in formautosubmit
Browse files Browse the repository at this point in the history
Ideally we shouldn't get into this situation, but in cases where the
generated select element is incorrectly configured, we should try and
handle it gracefully with a warning.
  • Loading branch information
Andrew Robert Nicols committed Jan 11, 2013
1 parent 10ad21d commit 86132c3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/yui/formautosubmit/formautosubmit.js
Expand Up @@ -40,9 +40,17 @@ YUI.add('moodle-core-formautosubmit',
}

// Assign this select items 'nothing' value and lastindex (current value)
var thisselect = Y.one('select#' + this.get('selectid'));
thisselect.setData('nothing', this.get('nothing'));
thisselect.setData('startindex', thisselect.get('selectedIndex'));
if (this.get('selectid')) {
var thisselect = Y.one('select#' + this.get('selectid'));
if (thisselect) {
if (this.get('nothing')) {
thisselect.setData('nothing', this.get('nothing'));
}
thisselect.setData('startindex', thisselect.get('selectedIndex'));
} else {
Y.log("Warning: A single_select element was renderered, but the output is not displayed on the page.");
}
}
},

/**
Expand Down

0 comments on commit 86132c3

Please sign in to comment.