Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.9
-
Fix Version/s: None
-
Component/s: Forms Library
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
Description
In the file
{moodesite}/lib/pear/HTML/QuickForm/checkbox.php there is a problem in the definition.
function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_text = $text;
$this->setType('checkbox');
$this->updateAttributes(array('value'=>1));
$this->_generateId();
} //end constructor
As you see, the value is always set to 1 no matter what developer sets in the addElement function.
I think you need to check to see if a value if given. If one is given, no need to set the value =1.
For example,
function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_text = $text;
$this->setType('checkbox');
if (!isset($this->_attributes['value']) ) {
$this->updateAttributes(array('value'=>1));
}
$this->_generateId();
} //end constructor
This way, the value is only set to 1 if no value is given.
In doing more research on this, l found that the forms element has an array called [_elementIndex] => Array
This array has the location of the items in the array.
The getElementType function in QuickForm.php depends on this.
But when you had items to a group, the items are not part of this index hence getElementType fails.
It would be nice if getElementType can recurse or somehow find item types in a Groups. Or just add the items in the Groups to this index array.