How to retreive form name - (CreateFormStart generated)

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
nervino
Power Poster
Power Poster
Posts: 448
Joined: Sun Dec 28, 2008 12:15 pm
Location: Roma, Italy

How to retreive form name - (CreateFormStart generated)

Post by nervino »

Hi All,
I'm using CreateFormStart to make a Form that has several checkboxes in it. In the template I put a javascript with a "select all" function and a HREF that fires this function.
Is there a way to grab the form's name generated by CreateFormStart()?

I've read the source of the parsed page and the form's name is "m1_moduleform_2".
If I put this name in the HREF it works:

Code: Select all

<a href="javascript:SetAllCheckBoxes('m1_moduleform_2', 'delete[]', true);">
but, is it posible to dynamically retreive the form's name?

Thank you
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: How to retreive form name - (CreateFormStart generated)

Post by Ted »

There's no way to retrieve the form's name.  But, you could pass a 'class="targetme"' into the $extra parameter.  Then grab the first item from getElementFromClassName('targetme');, assuming you have a library (or grab one from google -- http://robertnyman.com/2008/05/27/the-u ... anno-2008/).

Not a perfect solution, but it works.
nervino
Power Poster
Power Poster
Posts: 448
Joined: Sun Dec 28, 2008 12:15 pm
Location: Roma, Italy

Re: How to retreive form name - (CreateFormStart generated)

Post by nervino »

Ted wrote:
Not a perfect solution, but it works.
That's important! Thank you Ted, I'll try it.
NaN

Re: How to retreive form name - (CreateFormStart generated)

Post by NaN »

Whenever i use 'class="myForm"' or 'name="myForm"' in the extra parameter of CreateFormStart()
i get 'class="myForm"'.
This is because the function cms_module_CreateFormStart() in the lib/modform.inc.php converts everything that is passed to that function with cms_htmlentities(); into HTML entities.

So what is the $extra param for if i cannot use quotes ???
Last edited by NaN on Mon May 11, 2009 11:05 am, edited 1 time in total.
NaN

Re: How to retreive form name - (CreateFormStart generated)

Post by NaN »

NaN wrote:
So what is the $extra param for if i cannot use quotes ???
May i point someones interest in this question again?
I know i just need to disable one line in the modform.inc.php.
But is this really neccessary?
I mean who enters the $extra param when creating a form by using the cmsms module api function CreateFormStart()?
I believe there is no other man than a developer.
It is not possible to inject malicious code from outside with a classname oder a name attribute of form.
And no developer would use weird strings when calling this function.

So again, why is the $extra param converted with cms_htmlentities() ???
In my opinion there is no need to do this, isn't it?
Post Reply

Return to “Developers Discussion”