PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #3876

Pass parameters to form rules

Details

Request #3876Pass parameters to form rules
Submitted2005-03-18 19:31 UTC
Fromherojoker at nexgo dot de
StatusDuplicate
PackageHTML_QuickForm
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-03-18 19:31 UTC] herojoker at nexgo dot de

Description:
------------
I think it would be quite useful to pass parameters to form rules.
I have built a rule which checks whether at least one field has been filled in, but now there is a problem with the submit button (which has to have a name for some reasons) which passes a value and is element of the form (that's my check).
So a method

$form->addRule('myFormRule', $params)

would be nice.
Thanks in advance!
Hero Wanders

[2005-03-18 23:26 UTC] bmansion at mamasam dot com

use addFormRule() for this kind of validation.

[2005-03-19 12:22 UTC] herojoker at nexgo dot de

Hi!
Arg, I _used_ addFormRule($rule) for that (I just wrote it wrong here).
So I'm calling

$form->addFormRule(array($this, 'checkFields'));

I think it would be nice to pass something other than the callback to addFormRule().
Perhabs like that:

$form->addFormRule(array($this, 'checkFields'), array('myElement1', 'myElement2'));

checkFields() would have the following signature:
function checkFields(&$fields, $params)
($params would be array('myElement1', 'myElement2'))

It's just the same as with addRule(). There you can pass arguments. Why not so with addFormRule()?

Perhaps you can understand my request now (and not entitle it as bogus...).

Thank you for your great work with HTML_QuickForm,
Hero Wanders