previousHTML_QuickForm::setElementError() (Previous) (Next) HTML_QuickForm::getRegisteredRules()next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

HTML_QuickForm::registerRule()

HTML_QuickForm::registerRule() – 新しい検証規則を登録する

Synopsis

require_once 'HTML/QuickForm.php';

void HTML_QuickForm::registerRule ( string $ruleName , string $type , string $data1 , string $data2 = = null )

Description

新しい検証規則を登録します。

Parameter

string $ruleName

検証規則の名前。

string $type

'regex' あるいは 'callback' (過去との互換性のため、'function' も使用できます)。 HTML_QuickForm_Rule のサブクラスを登録する場合は、 ここで何でも渡すことができます。できれば NULL あるいは空の文字列にしましょう。

string $data1

関数の名前、正規表現、HTML_QuickForm_Rule のサブクラスの名前あるいはクラスのインスタンス。

コールバック関数は、その規則に通過したかどうかを true または false で返す必要があります。

string $data2

上の関数の親オブジェクト、あるいは HTML_QuickForm_Rule のサブクラスを含むファイルの名前。

Throws

例外はスローされません。

Note

since 1.0

This function can not be called statically.

previousHTML_QuickForm::setElementError() (Previous) (Next) HTML_QuickForm::getRegisteredRules()next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: kguest
One example of this is:

$form->registerRule('phone','regex', '/^[\d\-\.\s]+$/');

this rule will only allow numeric phone numbers with an optional separator between each grouping of numbers.
Separator may be either a space, hyphen, full-stop/period.