Where are Submitted Form values stored?

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
marshy

Where are Submitted Form values stored?

Post 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?
marshy

Re: Where are Submitted Form values stored?

Post by marshy »

*BUMP*
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Where are Submitted Form values stored?

Post 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
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Where are Submitted Form values stored?

Post 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
marshy

Re: Where are Submitted Form values stored?

Post 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?
marshy

Re: Where are Submitted Form values stored?

Post 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?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Where are Submitted Form values stored?

Post 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?
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
marshy

Re: Where are Submitted Form values stored?

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Where are Submitted Form values stored?

Post by calguy1000 »

You're not using that in a UserDefinedTag right?  it won't work there.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
marshy

Re: Where are Submitted Form values stored?

Post by marshy »

No, this is located in the default action of my module.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Where are Submitted Form values stored?

Post 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
Last edited by Anonymous on Wed Apr 25, 2007 9:51 am, edited 1 time in total.
marshy

Re: Where are Submitted Form values stored?

Post 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
)
marshy

Re: Where are Submitted Form values stored?

Post 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?
marshy

Re: Where are Submitted Form values stored?

Post by marshy »

Can anyone help me with this?
rtkd
Forum Members
Forum Members
Posts: 126
Joined: Tue Dec 12, 2006 3:57 pm

Re: Where are Submitted Form values stored?

Post 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
Post Reply

Return to “Developers Discussion”