mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-78527 pear: Adding attributes parameter to groups
This commit is contained in:
parent
0122c2c3e7
commit
313da3ebf3
@ -576,7 +576,7 @@ class HTML_QuickForm extends HTML_Common {
|
||||
$includeFile = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][0];
|
||||
include_once($includeFile);
|
||||
$elementObject = new $className(); //Moodle: PHP 5.3 compatibility
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
if (!isset($args[$i])) {
|
||||
$args[$i] = null;
|
||||
}
|
||||
@ -724,12 +724,13 @@ class HTML_QuickForm extends HTML_Common {
|
||||
* @param string $separator (optional)string to separate elements
|
||||
* @param bool $appendName (optional)specify whether the group name should be
|
||||
* used in the form element name ex: group[element]
|
||||
* @param mixed $attributes Either a typical HTML attribute string or an associative array
|
||||
* @return object reference to added group of elements
|
||||
* @since 2.8
|
||||
* @access public
|
||||
* @throws PEAR_Error
|
||||
*/
|
||||
function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appendName = true)
|
||||
function &addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = true, $attributes = null)
|
||||
{
|
||||
static $anonGroups = 1;
|
||||
|
||||
@ -737,7 +738,7 @@ class HTML_QuickForm extends HTML_Common {
|
||||
$name = 'qf_group_' . $anonGroups++;
|
||||
$appendName = false;
|
||||
}
|
||||
$group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName);
|
||||
$group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName, $attributes);
|
||||
return $group;
|
||||
} // end func addGroup
|
||||
|
||||
|
@ -383,10 +383,12 @@ class HTML_QuickForm_element extends HTML_Common
|
||||
{
|
||||
switch ($event) {
|
||||
case 'createElement':
|
||||
static::__construct($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]);
|
||||
static::__construct($arg[0], $arg[1], $arg[2], $arg[3], $arg[4], $arg[5]);
|
||||
if ($caller->getAttribute('data-random-ids') && !$this->getAttribute('id')) {
|
||||
$this->_generateId();
|
||||
$this->updateAttributes(array('id' => $this->getAttribute('id') . '_' . random_string()));
|
||||
$attributes = $this->getAttributes();
|
||||
$attributes['id'] = $this->getAttribute('id') . '_' . random_string();
|
||||
$this->updateAttributes($attributes);
|
||||
}
|
||||
break;
|
||||
case 'addElement':
|
||||
|
@ -88,12 +88,13 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
|
||||
* @param bool $appendName (optional)whether to change elements' names to
|
||||
* the form $groupName[$elementName] or leave
|
||||
* them as is.
|
||||
* @param mixed $attributes Either a typical HTML attribute string or an associative array
|
||||
* @since 1.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) {
|
||||
parent::__construct($elementName, $elementLabel);
|
||||
public function __construct($elementName = null, $elementLabel = null, $elements = null, $separator = null, $appendName = true, $attributes = null) {
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
$this->_type = 'group';
|
||||
if (isset($elements) && is_array($elements)) {
|
||||
$this->setElements($elements);
|
||||
@ -104,6 +105,9 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
|
||||
if (isset($appendName)) {
|
||||
$this->_appendName = $appendName;
|
||||
}
|
||||
if (isset($attributes)) {
|
||||
$this->_attributes = $attributes;
|
||||
}
|
||||
} //end constructor
|
||||
|
||||
/**
|
||||
@ -111,7 +115,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
|
||||
*
|
||||
* @deprecated since Moodle 3.1
|
||||
*/
|
||||
public function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) {
|
||||
public function HTML_QuickForm_group($elementName = null, $elementLabel = null, $elements = null, $separator = null, $appendName = true, $attributes = null) {
|
||||
debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
|
||||
self::__construct($elementName, $elementLabel, $elements, $separator, $appendName);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ MDL-77164 - PHPdocs corrections
|
||||
MDL-78145 - PHP 8.2 compliance. Added a missing class property that still need to be declared
|
||||
to avoid dynamic properties deprecated error warning.
|
||||
And also remove the $_elementIdx because it is not needed in Moodle code.
|
||||
MDL-78527 - Adding a sixth parameter to allow groups to use attributes.
|
||||
|
||||
Pear
|
||||
====
|
||||
|
Loading…
x
Reference in New Issue
Block a user