Re: Formbuilder $fb_linkNewValue: Bug or Feature?
| From: | led_belly | Date: | Tue, 22 Aug 2006 22:28:38 +0000 |
| Subject: | Re: Formbuilder $fb_linkNewValue: Bug or Feature? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24962@lists.php.net to get a copy of this message | ||
Ahh yes. Good information to have for the future. I came across
'fieldsRequired' and I am using that now. Much easier.
Justin Patrin wrote:
>
> 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:
>>
>> function postGenerateForm(&$form)
>> {
>> $form->addRule('urlstart', 'You must supply a starting
>> URL.',
>> 'required');
>> $form->addRule('merchantid_ga_merchants__urlstart', "You must
>> supply
>> a 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?
>
> 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 Patrin
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
View this message in context: http://www.nabble.com/Formbuilder-%24fb_linkNewValue%3A-Bug-or-Feature--tf2148327.html#a5934812
Sent from the Pear - General forum at Nabble.com.