Re: HTML_QuickForm2 rule chaining
| From: | Alexey Borzov | Date: | Thu, 27 May 2010 07:39:36 +0000 |
| Subject: | Re: HTML_QuickForm2 rule chaining | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30579@lists.php.net to get a copy of this message | ||
Hi Christian,
On 26.05.2010 21:25, Christian Weiske wrote:
I thought about your proposal a bit and I don't think it is a good idea to implement it. Reason: there are some subtle differences in how the Rules added directly to the Element and chained Rules work. Thus if we make addRule() look like Rule chaining we are greatly increasing the WTF factor. I don't think that is justified by saving a few keystrokes...Better idea: Add addRule() to Rule.php itself: public function addRule($rule, $message = '', $options = null) {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.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.