diff --git a/lib/formslib.php b/lib/formslib.php
index 8bb5b1f358c..c5605c7e10f 100644
--- a/lib/formslib.php
+++ b/lib/formslib.php
@@ -1724,14 +1724,23 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
}
if (isset($this->_advancedElements[$name])){
+ // this is tricky - the first submit button on form is "clicked" if user presses enter
+ // we do not want to "submit" using advanced button if javascript active
$showtext="'".get_string('showadvanced', 'form')."'";
$hidetext="'".get_string('hideadvanced', 'form')."'";
//onclick returns false so if js is on then page is not submitted.
$onclick = 'return showAdvancedOnClick(this, '.$hidetext.', '.$showtext.');';
- $button = '';
- $header_html =str_replace('{button}', $button, $header_html);
+ $button_js = '';
+ $button_nojs = '';
+ $button = ''; // the extra div should fix xhtml validation
+
+ $header_html = str_replace('{button}', $button, $header_html);
} else {
- $header_html =str_replace('{button}', '', $header_html);
+ $header_html = str_replace('{button}', '', $header_html);
}
if ($this->_fieldsetsOpen > 0) {