Page 1 of 1

I would like some static Form IDs

Posted: Fri Sep 21, 2007 12:19 am
by FantomCircuit
In a module I am developing, I need to attach some javascript via the form id. However, if other forms etc are added to the page, the form id changes.

eg// it goes from m6moduleform1 to m6moduleform2

This breaks all the javascript. Is there anyway to over-ride the form ids without breaking the form processing?

Re: I would like some static Form IDs

Posted: Fri Sep 21, 2007 12:38 am
by FantomCircuit
Typical me, not acutally looking at the problem first *sigh*

it seems that the id of the form does not matter to cmsms. Is this correct? i manually set the form tag and id, and the form still seemed to work fine. Does anyone know if any functionality actually relies on the form id?

If not, why can't we directly control what the form id will be.

Re: I would like some static Form IDs

Posted: Fri Sep 21, 2007 1:15 am
by calguy1000
The ID does matter.  Only parameters that match that ID are directed to the module.

If you want to use javascript on some of the module output, then I suggest you assign the form id to a smarty variable, and use that in your templates.

i.e:  $smarty->assign('formid',$id);
and then in your template, you can prefix all of the javascript stuff with {$formid}.  Of course it gets ugly with all the {literal} and {/literal} tags, but it can be done.

I'd suggest you do something like this:
{literal}
// some javascript code above including the script tag.
var formid = {/literal}{$formid}{/literal}
// some more javascript code

{/literal}

Re: I would like some static Form IDs

Posted: Fri Sep 21, 2007 1:19 am
by FantomCircuit
Oh, ok.

Hmm, good idea - thanks a lot for your help calguy!

Re: I would like some static Form IDs

Posted: Fri Sep 21, 2007 1:20 am
by calguy1000
Also, you can look at the FLVPlayer's summary and detail templates for example of integrating javascript into module output.