Page 1 of 1

Where are Submitted Form values stored?

Posted: Thu Apr 19, 2007 8:10 pm
by marshy
I am creating a form using CreateFormStart and CreateInputText and was wondering how CMSMS processes the submitted data.
I know that $_GET and $_POST are processed and stored in a variable somewhere but I cannot remember where.  Can someone point me in the right direction?

Re: Where are Submitted Form values stored?

Posted: Sun Apr 22, 2007 5:34 pm
by marshy
*BUMP*

Re: Where are Submitted Form values stored?

Posted: Mon Apr 23, 2007 12:36 pm
by Dee
You pass a name variable to CreateInputText (the 2nd parameter). After the submit the submitted data is available in $params, so $params['name'].

Regards,
D

Re: Where are Submitted Form values stored?

Posted: Mon Apr 23, 2007 12:43 pm
by Dee
You also pass a action variable to CreateFormStart (also the 2nd parameter) to indicate which action should be done when the form is submitted, $params will be available in that action after the submit.

Regards,
D

Re: Where are Submitted Form values stored?

Posted: Tue Apr 24, 2007 2:13 pm
by marshy
I have used CreateInputBox and specified names for them, but when I submit the form and view $params, the InputText names have changed.
The first inputText has the correct name (test1) but then each input text has a different name (such as 0, 1, 2, eth).
Any ideas why it is doing this?

Re: Where are Submitted Form values stored?

Posted: Tue Apr 24, 2007 7:50 pm
by marshy
To illustrate, the form is created and CMSMS creates 3 input boxes with names ord089345, ord149249, & ord149650.
When I submit some data in these boxes, $params displays this:

Code: Select all

Params
Array
(
    [returnid] => 66
    [089345] => A1
    [0] => B1
    [1] => C1
    [Submit] => Add
    [action] => default
)
As you can see, the first input box has the correct name and value but the others do not.
Why?

Re: Where are Submitted Form values stored?

Posted: Tue Apr 24, 2007 7:57 pm
by calguy1000
if you have:

Code: Select all

$this->CreateInputText($id,'textfield');  
in your module

then in the action that receives the results, you should be able to do an:

Code: Select all

echo $params['textfield'];
I use code like this a thousand times.

maybe you could provide a snippet?

Re: Where are Submitted Form values stored?

Posted: Tue Apr 24, 2007 9:44 pm
by marshy
This is the line of code that I am using:

Code: Select all

{$this->CreateInputText($id,$row['ProductNo'], 0, 5, 5, 'style=\"width: 30px\"')}
It is used in a loop that pulls product data from a table and uses $row['ProductNo'] as the name.

Re: Where are Submitted Form values stored?

Posted: Tue Apr 24, 2007 9:52 pm
by calguy1000
You're not using that in a UserDefinedTag right?  it won't work there.

Re: Where are Submitted Form values stored?

Posted: Wed Apr 25, 2007 7:08 am
by marshy
No, this is located in the default action of my module.

Re: Where are Submitted Form values stored?

Posted: Wed Apr 25, 2007 9:50 am
by Dee
I don't see any problem (except for the style statement that shouldn't be escaped):

Code: Select all

$entries = array (
	array('Id' => 1, 'ProductNo' => 'test2'),
	array('Id' => 2, 'ProductNo' => 'test4'),
	array('Id' => 3, 'ProductNo' => 'test7'),
);
foreach ($entries as $row)
{
	echo $this->CreateInputText($id,$row['ProductNo'], 0, 5, 5, 'style=\"width: 30px\"');
}
Output:

Code: Select all

<input type="text" name="m4test2" id="m4test2" value="0" size="5" maxlength="5" style=\"width: 30px\" />
<input type="text" name="m4test4" id="m4test4" value="0" size="5" maxlength="5" style=\"width: 30px\" />
<input type="text" name="m4test7" id="m4test7" value="0" size="5" maxlength="5" style=\"width: 30px\" />
(m4 is the module ID assigned to the module instance)
After submit the entered values will be available as $params['test2'], $params['test4'] and $params['test7'].

Regards,
D

Re: Where are Submitted Form values stored?

Posted: Wed Apr 25, 2007 2:03 pm
by marshy
I tried your example and it worked as expected.
However I think I have tracked the cause of my issue.
Some of my Input boxes have names that begin with 1, 2, 3, etc.
For some reason CMSMS seems to have a problem with this.
If you would like to see this for yourself, create a module with this code then look at the submitted data in params.
Code:

Code: Select all

echo $this->CreateFormStart( $id, $params['action'], $returnid, 'post', '', false, '' );

	$entries = array (
		array('Id' => 1, 'ProductNo' => '01234'),
		array('Id' => 2, 'ProductNo' => '02345'),
		array('Id' => 3, 'ProductNo' => '32345'),
		array('Id' => 4, 'ProductNo' => '22356'),
		array('Id' => 5, 'ProductNo' => '12356'),
	);

	foreach ($entries as $row)
	{
		echo $this->CreateInputText($id,$row['ProductNo'], 0, 5, 5, 'style="width: 30px"');
	}

	echo $this->CreateInputSubmit($id, 'Submit', 'Add', '', '', '');

	echo $this->CreateFormEnd();

HTML produced:

Code: Select all

<input type="text" name="ord01234" id="ord01234" value="0" size="5" maxlength="5" style="width: 30px" />
<input type="text" name="ord02345" id="ord02345" value="0" size="5" maxlength="5" style="width: 30px" />
<input type="text" name="ord32345" id="ord32345" value="0" size="5" maxlength="5" style="width: 30px" />
<input type="text" name="ord22356" id="ord22356" value="0" size="5" maxlength="5" style="width: 30px" />
<input type="text" name="ord12356" id="ord12356" value="0" size="5" maxlength="5" style="width: 30px" />
The result is:

Code: Select all

ParamsArray
(
    [returnid] => 66
    [01234] => 1
    [02345] => 2
    [0] => 3
    [1] => 4
    [2] => 5
    [Submit] => Add
    [action] => default
)

Re: Where are Submitted Form values stored?

Posted: Thu Apr 26, 2007 10:49 am
by marshy
Could someone tell me which file contains the code that processes a form on submit and puts the values into $params?
I would like to take a look to see if I can work out why this is happening.
If this is a bug how do I go about submitting it?

Re: Where are Submitted Form values stored?

Posted: Tue May 01, 2007 12:07 pm
by marshy
Can anyone help me with this?

Re: Where are Submitted Form values stored?

Posted: Mon May 07, 2007 10:21 am
by rtkd
hi,

i dont think this is a specific cmsms problem.

i can remember working on a project a couple of years ago, and i had the same problem.

http://www.w3.org/TR/html4/types.html#type-cdata
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
greets, rootkid