Nette 2.1.1 addRule with my function

Notice: This thread is very old.
motorcb
Member | 552
+
0
-

How to call my function in Nette 2.1.1 in rule in form?

        $form->addText( 'numberx', 'Number:' )
                ->addRule('divisibilityValidator', 'Number muss be div %d.', 8);
...

    function divisibilityValidator($item, $arg)
    {
        echo "xxx";
        return $item->value % $arg === 0;
    }

Error: Unknown operation ‘divisibilityValidator’ for control ‘numberx’

petr.pavel
Member | 535
+
0
-

How about ->addRule('classname::divisibilityValidator', ...
or ->addRule($this->divisibilityValidator, ...(if applicable)