MDL-36934 Only set the autosubmit class on selects when required
authorAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Fri, 30 Nov 2012 09:54:37 +0000 (09:54 +0000)
committerAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Sat, 1 Dec 2012 09:48:42 +0000 (09:48 +0000)
The url_select class can optionally show a button (much like the non-JS
fallback). In this case, the autosubmit nature of the form shouldn't be
enforced and it should only submit on the button.

lib/outputrenderers.php

index 3d7f410..0e8052d 100644 (file)
@@ -1565,9 +1565,15 @@ class core_renderer extends renderer_base {
             $output .= html_writer::label($select->label, $select->attributes['id'], false, $select->labelattributes);
         }
 
-        $select->attributes['class'] = 'autosubmit';
+        $classes = array();
+        if (!$select->showbutton) {
+            $classes[] = 'autosubmit';
+        }
         if ($select->class) {
-            $select->attributes['class'] .= ' ' . $select->class;
+            $classes[] = $select->class;
+        }
+        if (count($classes)) {
+            $select->attributes['class'] = implode(' ', $classes);
         }
 
         if ($select->helpicon instanceof help_icon) {