Re: FormBuilder postGenerateForm + elementNamePrefix rules issue

From: Date: Fri, 12 May 2006 04:36:04 +0000
Subject: Re: FormBuilder postGenerateForm + elementNamePrefix rules issue
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24051@lists.php.net to get a copy of this message
On 5/11/06, Justin Patrin <papercrane@gmail.com> wrote:
On 5/11/06, Paul Hinze <paul.t.hinze@gmail.com> wrote: On 5/11/06, Justin Patrin <papercrane@gmail.com> wrote:
Yep. This is one of the quirks having to do with the prefix/postfix options. Use $fb->getFieldName('username') instead of 'username'.
That makes sense, but I don't think I can get a FormBuilder in context during postGenerateForm, and the QuickForm that is passed in doesn't seem to have an equivalent function. Of course you can. It's the second parameter. http://pear.reversefold.com/dokuwiki/doku.php?id=pear:db_dataobject_formbuilder:callback_methods#postgenerateform_form_formbuilder
Well, there goes my trying-not-to-look-like-a-newbie cover. :-) $fb->getFieldName() works just fine.
As for replacing the messages...I'm not quite sure. It *could* be possible to add support to FB for element specific messages or perhaps there's a way to remove the rule with QF.
Removing rules with QF was my first thought, and I scoured the docs for a way of doing this. Oddly, the only thing I found was the $removeRules parameter for removeElement. I thought getRegisteredRules would give me access to change the existing rules, but it looks like it's really more like getRegisteredRuleTypes. Rather unclear. It seems that there really should be *some* way of accessing rules once they're added-- that would be the easiest my problem rather than going to all of the trouble of building per-element messages into FB (not that it would be impossible... I can picture promoting requiredMessage from scalar to array with functionality similar to fieldLabels). Anyone have ideas? Perhaps $form->insertElementBefore($form->removeElement('field', true), 'elementAfter'); If removeElement() can remove rules then there should be a public function to do the same thing. I suggets filing a feature request.
Request #7608 filed for HTML_QuickForm: http://pear.php.net/bugs/bug.php?id=7608
-- Justin Patrin
Thanks again for all your help, Justin. Paul Hinze

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