]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16036: make the default value in popup_form "selected"
authorscyrma <scyrma>
Mon, 18 Aug 2008 06:40:41 +0000 (06:40 +0000)
committerscyrma <scyrma>
Mon, 18 Aug 2008 06:40:41 +0000 (06:40 +0000)
lib/weblib.php

index 5cab18a80bbe530821eab9d1b30f66e41bc28e7e..e992fe9ae6e106d2caced6570500b4afd4b994c6 100644 (file)
@@ -1101,7 +1101,16 @@ $targetwindow='self', $selectlabel='', $optionsextra=NULL) {
     }
 
     if ($nothing != '') {
-        $output .= "   <option value=\"javascript:void(0)\">$nothing</option>\n";
+        $selectlabeloption = '';
+        if ($selected=='') {
+            $selectlabeloption = ' selected="selected"';
+        }
+        foreach ($options as $value => $label) {  //if one of the options is the empty value, don't make this the default
+            if ($value == '') {
+                $selected = '';
+            }
+        }
+        $output .= "   <option value=\"javascript:void(0)\"$selectlabeloption>$nothing</option>\n";
     }
 
     $inoptgroup = false;