From 43914931f7cafa7cd52740091b753f1e0aa52482 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Fri, 6 Jul 2007 04:03:51 +0000 Subject: [PATCH] validation can return an empty array() or true to indicate no errors. array() is preferred since then parent class validation functions can be chained. Changing moodle_form validation method to return array() so that chaining works in question types. Shouldn't affect other forms code. --- lib/formslib.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index b50db7642de..bd03590cc59 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -448,13 +448,9 @@ class moodleform { * @return bool array of errors or true if ok */ function validation($data) { - return true; + return array(); } - - - - /** * Method to add a repeating group of elements to a form. * @@ -625,7 +621,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { * @var unknown_type */ var $_formName = ''; - + /** * String with the html for hidden params passed in as part of a moodle_url object for the action. Output in the form. * @@ -1172,7 +1168,7 @@ function validate_' . $this->_formName . '_' . $elementName . '(element) { frm.elements[\''.$elementName.'\'].focus(); } '; - + // Fix for bug displaying errors for elements in a group //unset($element); //$element =& $this->getElement($elementName); @@ -1190,7 +1186,7 @@ function validate_' . $this->_formName . '(frm) { return true; } var ret = true; - + var frm = document.getElementById(\''. $this->_attributes['id'] .'\') var first_focus = false; ' . $validateJS . '; @@ -1363,7 +1359,7 @@ function validate_' . $this->_formName . '(frm) { } /** * Hard freeze all elements in a form except those whose names are in $elementList or hidden elements in a form. - * + * * This function also removes all previously defined rules of elements it freezes. * * @param array $elementList array or string of element(s) not to be frozen @@ -1483,7 +1479,7 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ 'fieldset'=>"\n\t\t".'
{label}{req} {advancedimg}
{help}
{error}
{element}
', 'static'=>"\n\t\t".'
{label}{req} {advancedimg}
{help}
{error}
{element} 
', - + 'nodisplay'=>''); parent::HTML_QuickForm_Renderer_Tableless(); @@ -1509,8 +1505,8 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ } else { $this->_hiddenHtml .= $form->_pageparams; } - - + + } function startGroup(&$group, $required, $error){