Re: QuickForm2 createrule

From: Date: Mon, 01 Oct 2012 07:33:31 +0000
Subject: Re: QuickForm2 createrule
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-31624@lists.php.net to get a copy of this message
Hi Adam, On 01.10.2012 5:27, Adam Tong wrote:
I would like to know the right syntax to pass a parameter to callback validation method. Here is the code: --------------- $passwd = $fieldSet->addElement('password','passwd')->setLabel('Password:');
     $passwd->addRule('required', "Please provide your password")
     ->and_($passwd->createRule('callback', 'Wrong password',
array($userDAO, 'checkPassword'))); -------------------- the checkPassword method will have automatically the content of the field password but I nead to add another parameter to the function (the user id).
You need to pass the following as the third argument to createRule(): array(
    'callback'  => array($userDAO, 'checkPassword'),
    'arguments' => array($someUserId)
) I think it is documented in the table: http://pear.php.net/manual/en/package.html.html-quickform2.rules.list.php

« previous php.pear.general (#31624) next »