Introduction - validation and filters (Previous) (Next) HTML_QuickForm::addGroupRule()

View this page in Last updated: Sun, 28 Sep 2008
English | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Plain HTML

HTML_QuickForm::addRule()

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

Beschreibung

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().

Parameter

mixed $element

Form element name(s). Currently the only builtin rule that expects and correctly handles an array here is compare:


<?php
$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. callback rules can also handle an array here, but the callback function you provide will obviously need to properly handle an array of values.

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 its original value if there is an error?

boolean $force

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

Hinweise

since 1.0

Diese Methode kann nicht statisch aufgerufen werden.

Introduction - validation and filters (Previous) (Next) HTML_QuickForm::addGroupRule()

Download Documentation Last updated: Sun, 28 Sep 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.