Fix fatal error because "date rule" was not defined.

1.10.x
Julio Montoya 11 years ago
parent 82e5898db0
commit 38c794855b
  1. 41
      main/inc/lib/pear/HTML/QuickForm.php
  2. 3
      main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php

@ -1087,21 +1087,52 @@ class HTML_QuickForm extends HTML_Common
* @access public
* @throws HTML_QuickForm_Error
*/
function addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false)
{
function addRule(
$element,
$message,
$type,
$format = null,
$validation = 'server',
$reset = false,
$force = false
) {
if (!$force) {
if (!is_array($element) && !$this->elementExists($element)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
return PEAR::raiseError(
null,
QUICKFORM_NONEXIST_ELEMENT,
null,
E_USER_WARNING,
"Element '$element' does not exist in HTML_QuickForm::addRule()",
'HTML_QuickForm_Error',
true
);
} elseif (is_array($element)) {
foreach ($element as $el) {
if (!$this->elementExists($el)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
return PEAR::raiseError(
null,
QUICKFORM_NONEXIST_ELEMENT,
null,
E_USER_WARNING,
"Element '$el' does not exist in HTML_QuickForm::addRule()",
'HTML_QuickForm_Error',
true
);
}
}
}
}
if (false === ($newName = $this->isRuleRegistered($type, true))) {
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
return PEAR::raiseError(
null,
QUICKFORM_INVALID_RULE,
null,
E_USER_WARNING,
"Rule '$type' is not registered in HTML_QuickForm::addRule()",
'HTML_QuickForm_Error',
true
);
} elseif (is_string($newName)) {
$type = $newName;
}

@ -150,7 +150,8 @@ class HTML_QuickForm_RuleRegistry
'username_available' => 'HTML_QuickForm_Rule_UsernameAvailable',
'compare_fields' => 'HTML_QuickForm_Compare_Fields',
'html' => 'HTML_QuickForm_Rule_HTML',
'CAPTCHA' => 'HTML_QuickForm_Rule_CAPTCHA'
'CAPTCHA' => 'HTML_QuickForm_Rule_CAPTCHA',
'date' => 'HTML_QuickForm_Rule_Date'
);
$class = $rules[$ruleName];

Loading…
Cancel
Save