MDL-65217 form: option to randomise element ids

This commit is contained in:
Marina Glancy
2019-04-29 14:23:27 +02:00
parent 521989ec56
commit f82c9d8d06
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -384,6 +384,10 @@ class HTML_QuickForm_element extends HTML_Common
switch ($event) {
case 'createElement':
static::__construct($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]);
if ($caller->getAttribute('data-random-ids') && !$this->getAttribute('id')) {
$this->_generateId();
$this->updateAttributes(array('id' => $this->getAttribute('id') . '_' . random_string()));
}
break;
case 'addElement':
$this->onQuickFormEvent('createElement', $arg, $caller);