From 28c7749fc7de5537871ac01caa0fab90b6e96378 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 13 Sep 2012 14:48:01 +0800 Subject: [PATCH] MDL-30909 Forms: Custom ID can be set on a form --- lib/formslib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index 412ce2b417c..03bb5f05202 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1301,13 +1301,15 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { } else { $this->_pageparams = ''; } - //no 'name' atttribute for form in xhtml strict : - $attributes = array('action'=>$action, 'method'=>$method, - 'accept-charset'=>'utf-8', 'id'=>'mform'.$formcounter) + $target; + // No 'name' atttribute for form in xhtml strict : + $attributes = array('action' => $action, 'method' => $method, 'accept-charset' => 'utf-8') + $target; + if (is_null($this->getAttribute('id'))) { + $attributes['id'] = 'mform' . $formcounter; + } $formcounter++; $this->updateAttributes($attributes); - //this is custom stuff for Moodle : + // This is custom stuff for Moodle : $oldclass= $this->getAttribute('class'); if (!empty($oldclass)){ $this->updateAttributes(array('class'=>$oldclass.' mform'));