Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-16242 "'Required' does nothing for select fields in customisable …

…user profiles" added an extra option 'Choose...' which is the default if no other default is specified. If the user leaves the select field set to 'Choose...' then the required rule fails and the form does not submit.
  • Loading branch information...
commit f1a022424de84507b17ee975fca84db07293db5e 1 parent 791a2be
jamiesensei authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 user/profile/field/menu/field.class.php
View
9 user/profile/field/menu/field.class.php
@@ -16,6 +16,9 @@ function profile_field_menu($fieldid=0, $userid=0) {
/// Param 1 for menu type is the options
$options = explode("\n", $this->field->param1);
$this->options = array();
+ if ($this->field->required){
+ $this->options[''] = get_string('choose').'...';
+ }
foreach($options as $key => $option) {
$this->options[$key] = format_string($option);//multilang formatting
}
@@ -40,7 +43,11 @@ function edit_field_add(&$mform) {
* Overwrites the base class method
*/
function edit_field_set_default(&$mform) {
- $defaultkey = (int)array_search($this->field->defaultdata, $this->options);
+ if (FALSE !==array_search($this->field->defaultdata, $this->options)){
+ $defaultkey = (int)array_search($this->field->defaultdata, $this->options);
+ } else {
+ $defaultkey = '';
+ }
$mform->setDefault($this->inputname, $defaultkey);
}
Please sign in to comment.
Something went wrong with that request. Please try again.