Re: Formbuilder $fb_linkNewValue: Bug or Feature?
| From: | Justin Patrin | Date: | Tue, 22 Aug 2006 20:10:26 +0000 |
| Subject: | Re: Formbuilder $fb_linkNewValue: Bug or Feature? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24960@lists.php.net to get a copy of this message | ||
On 8/22/06, led_belly <jacob-nospam@keystreams.com> wrote:
Hi, I posted yesterday with some problems that I was having with Formbuilder. Thanks for everyone's input on fixing that problem. Now I have a bit of curiosity regarding the behavior of $fb_linkNewValue: Is there a way to inherit the rules outlined in a classes postGenerateForm when --New Value-- is selected? As it is now I need to define for each calling form its relative form element name. For example, here is my postGenerateForm for a particular class:What you're missing is that when you have a subForm (linkNewValue makes a subForm) the element names are different. You need to use the second argument (&$fb) and $fb->getFieldName() to have this work correctly. function postGenerateForm(&$form, &$fb) { $form->addRule($fb->getFieldName('urlstart'), 'You must supply a starting URL.', 'required'); etc... -- Justin Patrinfunction postGenerateForm(&$form) { $form->addRule('urlstart', 'You must supply a starting URL.','required');$form->addRule('merchantid_ga_merchants__urlstart', "You must supplya starting URL.", 'required'); $form->addRule('merchantid_ga_merchants____crossLink_ga_merchant_categories_merchantid_categoryid', "You must select at least one category.", 'required'); $form->addRule('__crossLink_ga_merchant_categories_merchantid_categoryid', 'You must select at least one category.', 'required');$form->setDefaults(array('active' => 1)); }You'll notice that I have created two rules each for urlstart & categoryid that are the same; the only difference being if another form is calling it or it's being called natively. I might be missing a simple boolean flag somewhere. Any suggestions?