Re: HTML_QuickForm2 rule chaining

From: Date: Wed, 26 May 2010 17:25:01 +0000
Subject: Re: HTML_QuickForm2 rule chaining
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30571@lists.php.net to get a copy of this message
Hi Alexey, > > > When adding multiple rules to an qf2 element, using the fluent > > > interface does not work anymore - every addRule() call returns the > > > created rule and not the element. > > > I do see that this is needed for further rule modifications or > > > using them in and/or chains, it makes the simple cases more > > > complicated. > > > > > > What about a copy of addRule() that returns the qf element? > > 1) Please note that addElement() you are using in your example > > returns the added element rather than the form. Do we need > > addElementF() also? > That depends - if there are many things to do with a form object, > maybe yes. > > > 2) What exactly are you trying to achieve here? > > Saving a few keystrokes by not having to type $el a couple of times? > Yep, I would like to > a) not assign a variable at all > b) save keystrokes, get cleaner code - and more consistent code, since > the fluent interface is partly provided already. Currently the fluent > interface cannot be through the *whole* element setup process and > feels half-baken. Better idea: Add addRule() to Rule.php itself: public function addRule($rule, $message = '', $options = null) { return $this->owner->addRule($rule, $message, $options); } This would be consistent in the way that Rule.php already has _or() and _and() - plus the fluent interface would work fine. -- Regards/Mit freundlichen Grüßen Christian Weiske -=≡ Geeking around in the name of science since 1982 ≡=-

Attachment: [application/pgp-signature] signature.asc
« previous php.pear.general (#30571) next »