Forums

Form sends field names instead of data

Evopro 08 Jan, 2011
Hi there

Our samples form on our site worked well, with email verification until I made some change to the form code (added text).

Now the form returns form field names instead of data, like this:


Products: {check1}


Shipping Information:

Name: Johan Niklasson
Street Address: {text_14}
City: {text_16}
State: {text_18}
Zip Code: {text_19}



What is wrong? We use the email verification plugin. Another issue is that the visitor, when clicking the email verification link is taken to a new browser window instead of the one that was pen while filling the form.

We need help!

Best Regards
Johan Niklasson
Evopro 08 Jan, 2011
Hi again

I now installed a backed up version of the form and also shut off the email verification plugin - now the form sends correct data so the problem seems to lie with the email verification plugin.

Any ideas?

Best Regards
Johan Niklasson
Evopro 08 Jan, 2011
Hi again

I set up a new table for the sample form and this time I marked all fields to be included. Now, the email with the form result does contain the data from most fields except one filed that is a checkbox field with many options. This works fine when the email verification is not on but as soon as I turn it on, that field is left empty.

Any ideas?

Best Regards
Johan Niklasson
Evopro 08 Jan, 2011
Hi again

Ok, so I went to the email verification table and unchecked the field which contains the data from the checkboxes in the form. Then the {check1} showed up again but the rest of the data seems to be collected from this database.

I have checked in the database and the field with the data from the checkboxes is not filled in in this table created for the email verification. I can have all other data from the form be placed there and that seems to be what is sent in the final emails.

When the email confirmation plugin is disabled, everything works well and the checkbox results are included in the emails.

It seems to me that when I activate the email confirmation plug in, the data from the form is being stored in this new table instead of the usual place and that would be OK if all data also would end up in the final emails!

So I now have managed to understand this - but still can not figure out how to see to that the data from the checkbox area in the form can be stored in the new email verification field and be included in the emails.

Please help!

Best Regards
Johan Niklasson
GreyHead 09 Jan, 2011
Hi Johan,

You are right, the plug-in takes over some of the form submission code and doesn't do it as well as the main extension. In this case it omits to do the array expansion for the checkboxes. The only way I can find to fix this is to hack the plug-in file (the execution sequence means that you can't use the OnSubmit code boxes in the plug-in itself).

If you edit components/com_chronocontact/plugins/cf_email_verification.php and look for this code around line 290 you can insert code to do the conversion.
	function onsubmit( $option, $params , $row ) {
		global $mainframe;
		$database =& JFactory::getDBO();
		$pluginrow = $row;
		$posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
		$formname = JRequest::getVar( 'chronoformname');
		$MyForm =& CFChronoForm::getInstance($formname);
		$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
		$MyCustomCode =& CFCustomCode::getInstance($MyForm->formrow->id);
		/* add the following 9 lines */
		// handle arrays
		if ( $MyForm->formparams('handlepostedarrays', 'Yes') == 'Yes' ) {
			foreach ( $posted as $name => $post ) {
				if ( is_array($post) ) {
					$posted[$name] = implode(", ", $post);
					JRequest::setVar($name, $posted[$name]);
				}
			}
		}
		/* end edit */
		//save the data
		$posted[$params->get('vflagfield')] = 0;
		if ( !empty($MyForm->formrow->autogenerated) ) {
			eval( "?>".$MyForm->formrow->autogenerated );
		}

Note that this still checks the 'Let ChronoForms handle your arrays' on the Form General tab.

Another issue is that the visitor, when clicking the email verification link is taken to a new browser window instead of the one that was pen while filling the form.

I may be missing something here. It has to be a new window as it's a click from an external link in an email. What do you want to happen?

Bob
Evopro 09 Jan, 2011
Dear Bob

Thanks, I will try this now.

Best Regards
Johan Niklasson
Evopro 09 Jan, 2011
Dear Bob

That change broke the whole chrono plugin.

Had to revert to a backup.

Best Regards
Johan Niklasson
GreyHead 09 Jan, 2011
Hi Johan,

Shame, it worked OK on my test site. When you say it broke the plug-in what exactly happened?

Bob
Evopro 09 Jan, 2011
Dear Bob

The main chronoforms page went white with just a few items left.

When placing your code in dreamweaver, the software alerted that there was a code error or syntax error but I thought it would work anyway.

Best Regards
Johan Niklasson
GreyHead 09 Jan, 2011
Hi Johan,

Hmmm the code was copied out of DreamWeaver with no errors showing.

Make sure that you just insert these lines and not the whole block (that would break the plug-in):
		/* add the following 9 lines */
		// handle arrays
		if ( $MyForm->formparams('handlepostedarrays', 'Yes') == 'Yes' ) {
			foreach ( $posted as $name => $post ) {
				if ( is_array($post) ) {
					$posted[$name] = implode(", ", $post);
					JRequest::setVar($name, $posted[$name]);
				}
			}
		}
		/* end edit */

If that doesn't do it I'll look again.

Bob
Evopro 10 Jan, 2011
Dear Bob

I now tried again - this time without breaking the chrono plugin but with the same final result - checkbox values are not sent (saved I guess) and I only get the field name returned.

Best Regards
Johan Niklasson
GreyHead 10 Jan, 2011
Hi Johan,

One more thing to check please. Do you have "ChronoForms handle my posted arrays" set to 'Yes' on the Form General tab?

Bob
Evopro 10 Jan, 2011
Dear Bob

I did, it is. I will wait for the next version of Chronoengine forms.

Best Regards
Johan Niklasson
This topic is locked and no more replies can be posted.