Prev: HTML_QuickForm2_Rule_Callback: inverting callback ruleresults
Next: does Mail_mimeDecode() constructor actually recognize 'crlf'param?
From: Christian Weiske on 4 May 2010 12:55 Hi all, 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? Instead of > $el = $form->addElement(..); > $el->addRule(...); > $el->addRule(...); > $el->addRule(...); one could use > $form->addElement(..) > ->addRuleE(...) > ->addRuleE(...) > ->addRuleE(...) What do you think about that? -- Regards/Mit freundlichen GrüÃen Christian Weiske -=â¡ Geeking around in the name of science since 1982 â¡=-
From: Alexey Borzov on 5 May 2010 11:11 Hi Christian, On 04.05.2010 20:55, Christian Weiske wrote: > 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? > Instead of >> $el = $form->addElement(..); >> $el->addRule(...); >> $el->addRule(...); >> $el->addRule(...); > one could use >> $form->addElement(..) >> ->addRuleE(...) >> ->addRuleE(...) >> ->addRuleE(...) > > What do you think about that? 1) Please note that addElement() you are using in your example returns the added element rather than the form. Do we need addElementF() also? 2) What exactly are you trying to achieve here? Saving a few keystrokes by not having to type $el a couple of times?
From: Christian Weiske on 5 May 2010 11:16 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. -- Regards/Mit freundlichen GrüÃen Christian Weiske -= Geeking around in the name of science since 1982 =-
From: Ken Guest on 5 May 2010 11:21 On Wed, May 5, 2010 at 4:16 PM, Christian Weiske <cweiske(a)cweiske.de> wrote: > Hi Alexey, <snip> >> 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. Would it be fair to say it is truly geborked? K. -- http://blogs.linux.ie/kenguest/
From: Christian Weiske on 26 May 2010 13:25
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 â¡=- |