Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9.2
-
Fix Version/s: None
-
Component/s: Forms Library
-
Labels:None
-
Difficulty:Easy
-
Affected Branches:MOODLE_19_STABLE
Description
Improving usability of question editing I found that code below result in error:
$mform->addElement('text',$repeatname,$repeatstring,array('size'=>3));
$mform->addElement('hidden', $repeathiddenname, $repeats);
$mform->addRule($repeatname,null,'required',null,'client',true);
$mform->addRule($repeatname,null,'nonzero',null,'client',true);
//$mform->addRule(array($repeatname, $repeathiddenname),'You can\'t delete blanks','compare','>=','client',true);//uncommenting this line results in error in getValidationScript
If you uncomment the last line you receive
"Fatal error: Call to a member function on a non-object in z:\home\moodle\www\lib\formslib.php"
The line with error is "$onBlur = $element->getAttribute('onBlur');" in function getValidationScript
Issue Links
| This issue will help resolve: | ||||
| MDL-17064 | Allow user to enter the required quantity of repeated elements in one page reload |
|
|
|
The core of the issue I think is the assumption, that $element part of the rule is always an element, while in 'compare' rule it must be an array. This will be pretty easy to fix. Could you please fix it because now it's a sort of blocker for repeat_elements improvement.