]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16242 "'Required' does nothing for select fields in customisable user profiles...
authorjamiesensei <jamiesensei>
Thu, 28 Aug 2008 06:44:49 +0000 (06:44 +0000)
committerjamiesensei <jamiesensei>
Thu, 28 Aug 2008 06:44:49 +0000 (06:44 +0000)
user/profile/field/menu/field.class.php

index c360b2ad95ac6167978a074a218b1c7d798986fc..fa60ab631d9f9768376dc43e595490d1a7eeb125 100644 (file)
@@ -16,6 +16,9 @@ class profile_field_menu extends profile_field_base {
         /// 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 @@ class profile_field_menu extends profile_field_base {
      * 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);
     }