HTML_QuickForm::addRule()

HTML_QuickForm::addRule() -- Adds a validation rule for the given field

Synopsis

require_once 'HTML/QuickForm.php';

void HTML_QuickForm::addRule (mixed $element, string $message, string $type [, string $format = '' [, string $validation = 'server' [, boolean $reset = FALSE [, boolean $force = FALSE]]]])

Описание

If the element is in fact a group, it will be considered as a whole, an array of group elements' values will be passed to validation function. To validate grouped elements as separate entities, use addGroupRule().

Параметр

mixed $element

Form element name(s). Currently the only builtin rule that expects and correctly handles an array here is compare:
$form->addElement('password', 'cmpPasswd', 'Password:');
$form->addElement('password', 'cmpRepeat', 'Repeat password:');
$form->addRule(array('cmpPasswd', 'cmpRepeat'), 'The passwords do not match', 'compare', null, 'client');
All other builtin rules will only handle a single element name.

string $message

Message to display for invalid data

string $type

Rule type, use getRegisteredRules() to get types. You can also pass a classname for a descendant of HTML_QuickForm_Rule or an instance of such class.

string $format

(optional) Required for extra rule data

string $validation

(optional) Where to perform validation: "server", "client"

boolean $reset

For client-side validation: reset the form element to it's original value if there is an error?

boolean $force

Force the rule to be applied, even if the target form element does not exist

Throws

Таблица 42-1. Возможные значения PEAR_Error

Error codeError messageReasonSolution
QUICKFORM_NONEXIST_ELEMENTElement '$element' does not exist in HTML_QuickForm::addRule()Tried to add a rule for a non-existant elementCheck the element's name spelling or use $force to suppress the error.
QUICKFORM_INVALID_RULERule '$type' is not registered in HTML_QuickForm::addRule()Rule is not known to QuickFormCheck rule type spelling or use HTML_QuickForm::registerRule().

Заметка

since 1.0

Эта функция не должна вызываться статически.


HIVE: All information for read only. Please respect copyright!
Hosted by hive йца: йХЕБЯЙЮЪ ЦНПНДЯЙЮЪ АХАКХНРЕЙЮ