Minor - format code.

1.10.x
Julio Montoya 10 years ago
parent 70ba623b6b
commit 76dca6eb4a
  1. 36
      main/inc/lib/pear/HTML/QuickForm.php
  2. 8
      main/inc/lib/pear/HTML/QuickForm/Rule/Required.php
  3. 3
      main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php

@ -1066,9 +1066,6 @@ class HTML_QuickForm extends HTML_Common
return $el;
} // end func removeElement
// }}}
// {{{ addRule()
/**
* Adds a validation rule for the given field
*
@ -1159,10 +1156,8 @@ class HTML_QuickForm extends HTML_Common
'reset' => $reset,
'dependent' => $dependent
);
} // end func addRule
}
// }}}
// {{{ addGroupRule()
/**
* Adds a validation rule for the given group of elements
@ -1207,12 +1202,13 @@ class HTML_QuickForm extends HTML_Common
}
$this->_rules[$elementName][] = array(
'type' => $type,
'format' => $format,
'message' => $rule[0],
'validation' => $validation,
'reset' => $reset,
'group' => $group);
'type' => $type,
'format' => $format,
'message' => $rule[0],
'validation' => $validation,
'reset' => $reset,
'group' => $group,
);
if ('required' == $type || 'uploadedfile' == $type) {
$groupObj->_required[] = $elementName;
@ -1224,6 +1220,7 @@ class HTML_QuickForm extends HTML_Common
}
}
}
if ($required > 0 && count($groupObj->getElements()) == $required) {
$this->_required[] = $group;
}
@ -1244,12 +1241,14 @@ class HTML_QuickForm extends HTML_Common
}
}
$this->_rules[$group][] = array('type' => $type,
'format' => $format,
'message' => $arg1,
'validation' => $validation,
'howmany' => $howmany,
'reset' => $reset);
$this->_rules[$group][] = array(
'type' => $type,
'format' => $format,
'message' => $arg1,
'validation' => $validation,
'howmany' => $howmany,
'reset' => $reset,
);
if ($type == 'required') {
$this->_required[] = $group;
}
@ -1620,7 +1619,6 @@ class HTML_QuickForm extends HTML_Common
} elseif (is_array($submitValue) && !isset($rule['howmany'])) {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
} else {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], false);
}

@ -1,5 +1,4 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Required elements validation
@ -40,7 +39,7 @@ class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
* @access public
* @return boolean true if value is not empty
*/
function validate($value, $options = null)
public function validate($value, $options = null)
{
// It seems this is a file.
if (is_array($value)) {
@ -51,19 +50,22 @@ class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
isset($value['error'])
){
if (empty($value['tmp_name'])) {
return false;
}
}
} else {
if ((string)$value == '') {
return false;
}
}
return true;
}
function getValidationScript($options = null)
public function getValidationScript($options = null)
{
return array('', "{jsVar} == ''");
}

@ -187,7 +187,6 @@ class HTML_QuickForm_RuleRegistry
function validate($ruleName, $values, $options = null, $multiple = false)
{
$rule =& $this->getRule($ruleName);
if (is_array($values) && !$multiple) {
$result = 0;
foreach ($values as $value) {
@ -195,8 +194,10 @@ class HTML_QuickForm_RuleRegistry
$result++;
}
}
return ($result == 0) ? false : $result;
} else {
return $rule->validate($values, $options);
}
} // end func validate

Loading…
Cancel
Save