Forums

[SOLVED] Chronforms CURL does not form a correct Array?

akerman 12 Jun, 2010
Hi,

CF is a wonderful extension and extremely useful. Thanks for all the good work! Will definitively purchase the license, as soon as this 'little' quirk is sorted out.

Environment:
Cronoforms v3.1 RC5.5
vTiger 5.1.0
Joomla! 1.15.15

Success:
Managed to -
A. Create Form
B. Create E-mail
C. Make CF take care of ALL Joomla User Reg (Switched off Joomla Core User Reg)
D. Set CF to only send one Welcome email
E. Use CURL plugin to populate vTiger with fields in the vTiger 'Leads Module' both custom fields
and standard fileds. (Secure posting with application key & WebForms key identification)
(vTiger has a 'post.php' file and a config file already made ready to recieve from ANY forms)

Issue:
Using tickboxes in CF form works. BUT it's only the Joomla Plugin that manage to form a successful Array.
The CURL plugin only writes 'Array' in the field. Noting else.

"ChronoForms handle my posted arrays: YES" (Tried different settings on this and other stuff)

Please see included Debug. Interesting Field in Red. Note the difference.
---------------------------------------------------------------------------------------------
cf_CURL debug info
$curl_values: company=Company+Name&firstname=MyName&lastname=Surname&email=akerman%40akermanscove.com&website=&phone=&mobile=&lane=SomeStreet+123&pobox=&code=123+55&city=Somecity&cf_548=Paket+1+-+Basic&cf_549=Array&cf_547=&appKey=85888888888888ccdb6f4e9946ab&moduleName=Leads&leadsource=Web+Site&leadstatus=From+Website+Not+Contacted& =&=
$params->target_url: http://akermanscove.com/sacrm/modules/Webforms/post.php
$ch: Resource id #115
CURL response: HTTP/1.1 200 OK Date: Sat, 12 Jun 2010 15:29:23 GMT Server: Apache/2.2.8 (Ubuntu) PHP/5.2.12-0.dotdeb.1 with Suhosin-Patch X-Powered-By: PHP/5.2.12-0.dotdeb.1 Content-Length: 1215 Content-Type: text/html
vtiger logo
Leads entry is added to vtiger CRM.
..............................................................
Joomla Message (You can logg in now... in Swedish)
Du kan logga in nu.
..............................................................
Inside cf_Joomla_registration::onSubmit()
$post: Array ( [company] => Company Name [firstname] => MyName [lastname] => Surname [fullname] => MyName Surname [email] => [email]auser@akermanscove.com[/email] [website] => [phone] => [mobile] => [lane] => SomeStreet 123 [pobox] => [code] => 123 55 [city] => Somecity [user_name] => MyNewUserName [user_password] => mypassw [user_password_verify] => mypassw [radio0] => Paket 1 - Basic [check1] => Array ( [0] => Paket 1 Basic [1] => Paket 2 Media [2] => Paket 3 E-handel ) [comments] => [chrono_verification] => 4bAtr [button_9] => Skicka [f01300bac63ee5d94686ac4a00f248b7] => 1 [1cf1] => d8a3d062fe2354e6a6bb22cf30b24dc0 [chronoformname] => SA_IntresseReg [username] => MyNewUserName [name] => MyName Surname [password] => mypassw [password2] => mypassw )

Välkommen MyName Surname!

Lorem Ipsum........emailtext here

Mvh

Robert O. Akerman

STOLT/AKERMAN HB

1. Form passed first SPAM check OK
2. Form passed the submissions limit (if enabled) OK
3. Form passed the Image verification (if enabled) OK
4. Form passed the server side validation (if enabled) OK
5. $_POST Array: Array ( [company] => Company Name [firstname] => MyName [lastname] => Surname [fullname] => [email] => [email]akerman@akermanscove.com[/email] [website] => [phone] => [mobile] => [lane] => SomeStreet 123 [pobox] => [code] => 123 55 [city] => Somecity [user_name] => MyNewUserName [user_password] => mypassw [user_password_verify] => mypassw [radio0] => Paket 1 - Basic [check1] => Array ( [0] => Paket 1 Basic [1] => Paket 2 Media [2] => Paket 3 E-handel ) [comments] => [chrono_verification] => 4bAtr [button_9] => Skicka [f01300bac63ee5d94686ac4a00f248b7] => 1 [1cf1] => d8a3d062fe2354e6a6bb22cf30b24dc0 [chronoformname] => SA_IntresseReg )
6. $_FILES Array: Array ( )
7. CURL transaction executed
8. Form passed the plugins step (if enabled) OK
9. Debug End

----------------------------------------------------------------------------------------------
So, since CURL doesn't succed with this, the multiple fields I've set up in vTiger never gets any info...obviously.

All ideas are welcome!
(all user/domain/mail details in the debug above are faked or altered)

Regards
Robert O. Akerman / stolt-akerman.com
GreyHead 12 Jun, 2010
Hi Robert,

There is a 'beta' version of the CURL Plugin here that fixes several bugs and adds a few features - I think including the ability to handle arrays.

Please run a quick check and see if this does what you need. I have a later version still but the helper files have been split into two parts and it is not compatible with the other current plugins.

Bob
nml375 12 Jun, 2010
Hi Akerman,
This seems rather odd, as the JURI::buildQuery() method (which the cURL plugin uses to build the query) should expand any arrays recursively.

Though, digging alittle deeper, the issue may originate from line 260 of plugins/cf_CURL.php, where the different values are read using JRequest::getVar() with the filter 'string'. Altering this to 'none' should do the trick.

/Fredrik

Edit: Ohh, Bob beat me to it. Give his suggestion a go.
akerman 13 Jun, 2010
Thank you for the high attention! Appreciate it.

Being a cautious person and fairly knowledgeable about coding, I took the 'slow' path.

1. I made backup of the files.
2. I tried editing the line at 260 first as directed above. (Noot keen on using beta in prod :-) )

Result: The page with the Form is just blank. No errors, nothing.
Cleaning cache settings in browser, in J! or even waiting for som 10 minutes - Still blank.

3. Reverted back to the original cf_CURL.php
Still blank
This morning - Hours after reverting back. The page is now visible again!?

This leads me to belive I'm missing some important information on how the CF component works with cache or how it stores information on either initial load or on page load...?

4. Then I tried the BETA - as per your instruction.
Same fault as above with the extra twist that now also the backend link to "Forms Management"
is blank, with the exception of the red field teleling me to validate the component.
(i.e. Buy it)

Thinking about it for a while I realize that the BETA test might be invalid -
Since I never saw the page again after the first editing test.... hmm.

Ideas, input corrections?


Regards
Robert O. Akerman / stolt-akerman.com
GreyHead 13 Jun, 2010
Hi Robert,

ChronoForms does nothing at all with caching as far as I am aware. It does use script files that are cached in the browser as usualy but I don't think that any of these would have this result?

Sorry about the beta version, sounds as though there is some PHP error being set off. If you set Site Error Reporting to Max you might get a more useful message. That version certainly has run been OK with the current release of ChronoForms.

Bob
akerman 13 Jun, 2010
Hi,

well, I agree. This is quite odd behaviour and I'll continue to analyse it.

Interestingly enough this quirk also happened upon editing the line 260, as directed above. Which is all very strange. For one, failure to run a .php script is indicated by errors (if anything wrong), second the alteration is more internal and should only have been indicated whilst the plugin was activated and run by the form.

Still, I know I've seen this before. Think it was when I made some heavy alterations on Virtuemart. It is likely connected to renaming the files.

As of now, I set filename like: 'cf_CURL_original.php' before copying new file.
I'll do some testing.


CF has worked perfect otherwise.

Regards
Akerman
akerman 13 Jun, 2010
....which did the trick!

So, renaming file 'cf_CURL.php' to 'cf_CURL.php' is not sufficient.
Obviously the inclusion script is only interested in the 'cf_' part, so all files in that folder that starts with 'cf_' are treated as plugins. Which is kind of logical since CF doesn't have an automated/backend process for handling plugins.

Recommend changing filenames to 'old_cf_CURL.php' or some other prefix you prefer. :-)

So, thanks for the script and the aid! I'll do some thorough testing today before closing the case (assuming the array issue is solved :-) )

Regards
Akerman
nml375 13 Jun, 2010
Hi Robert,
Actually, any files matching plugins/cf_*.php will be included whenever there is any interactions with the CFPlugins (such as listing the available plugins in the Forms Manager).
This has a very nasty side-effect if you keep a backup copy, as each plugin is expected to contain a class definition with the same name. However, in the case of a backup file, you'd have two files defining the same class, causing a fatal PHP error => White Screen.

Prefixing the backup-file with "old_" should work without any issues. Another option might be to change the extension from .php to .txt

/Fredrik
GreyHead 13 Jun, 2010
Hi Robert & Fredrik,

I usually just add .old to the end so the filename becomes cf_some_plugin.php.old

This keeps them out of the way and is easy to reverse.

Bob
akerman 14 Jun, 2010
Hi,

both valid and good suggestions!

However,

1. The Beta causes at least my installation to not show any 'tabs' in the component admin. Instead all 'tabs' are shown in a long trickily page on top of each other. Seems to be some faulty or missing CSS here. The effect being that some selection fields are just text. So, not usable and I couldn't test this fully.

2. The simple code change from 'string' to 'none' works in the sense that CURL now sends the field value as: cf_field= (1)Value1 (2)Value2 (3)Value3. The Joomla plugin still reporting that it recognizes the same field as Array - As described above. I would expect CURL to also reference the field similarly (as an Array). But no. And oh, vTiger looks at this cf_field and says -"What is this? Let's throw it away." :-)

So Array - Still unsolved I'm afraid.

Regards
Akerman
GreyHead 14 Jun, 2010
Hi Robert,

The beta is using the same Joomla tab code as the other plugins, so not sure why you'd get an odd display :-(

Bob
marcodeluca 03 Oct, 2010
This is a bit past now, but the beta cURL plugin that you downloaded is named cf_cURL.php. Chronoforms is looking for cf_CURL.php. The capital C. If you just make sure that the new php file is named the same as the old one ( that you hopefully renamed to cf_CURL.php.old or whatever rather than deleting ) the administrator formatting works fine.

As for the issues, Im not sure if you've had the same ones as me, but checkbox fields are not showing up correctly using the cURL plugin. I have a checkbox array with 3 items, but only two of the items show up in the cURL. What was happening was Chronoforms was creating a checkbox array like this:


<input value="1" title="" class="radio" id="check00" name="check0[]" type="checkbox" />
<input value="2" title="" class="radio" id="check01" name="check0[]" type="checkbox" />
<input value="3" title="" class="radio" id="check02" name="check0[]" type="checkbox" />

The name should have been "check0[], check1[], check2[]" or something. Modifying the code of the form afterwords solves the problem. Not sure if I did something wrong in the first place:)
GreyHead 03 Oct, 2010
Hi marcodeluca,

Sorry about the naming problem - my fault entirely. (The current version I have is called cf_curl to avoid some of these inadvertent mismatches.)

From memory neither the cURL, nor the ReDirect plug-ins handle array results correctly :-( I do have a working test version where this is fixed but it uses different helper files.

Bob
akerman 28 Oct, 2010
Hi...again.. 😀

thanks for the input Marco. And no.... it's not late to contribute to this thread..😀

One reaction from me though on your renaming of the name="" parameter. Setting different names on each "tickbox" actually makes them unique members of their own array. And as such they no longer form an actual array. They become individual "tickboxes" with one value per array.
(I'm not 100% on this but I think I am...)

My point is to form a true cURL array with several values in it, so I can export it into my CRM via a POST function.

However - I can confirm that your solution works and setting individual name="X" parameters without brackets in Chronoform form and then matching the vTiger custom field (cf_XXX) to this via cURL fills in the correct value (1 or 0) which vTiger then translate into "yes" or "no" respectively. DS

When/If I have something working - I will post it here.

------------------------------------------------------------------------------------------------
Grayhead,

no beer for you just yet, mate. 😀 But I got the Beta working as described above, seems I had some other issues simultaneously before. Now it's OK and I at least have some more cURL debugging info to work with. Yeeh...? :?

Still I think Chronoforms is one of the top Joomla! Form apps out there and I'm really hoping to solve this.

Regards
Akerman
akerman 30 Oct, 2010
Since my goal with this quest (issue? 😀 ) is to bring Chronoform form data into vtiger by using checkbox and multi-select combo box fields, these are my findings. Might be helpful to anyone else.

The primary challenge for me was figuring out how to get the data into the right format so that vtiger would properly process those fields. I don't think multi-select combo boxes are saved as true or separate array data in the vtiger db. They are simply saved as single text fields with a space+bar+##+bar+space separator between each entry (" |##| ").

Presumably, vtiger processes these fields at various points to create various arrays on the fly, but it seems that the data itself is saved in a single field.

So, if you haven't tried it already, you might try to concatenate or otherwise process the multi-select input field(s) from your Chronoform (Joomla form) data in your PHP processing script, and turn those fields into simple, single text fields containing multiple entries. Be sure to include a space on both sides of the |##| separator because otherwise vtiger misreads the field data.

Also, checkbox fields must use 1 and 0, not yes and no, if that makes any difference.

(Some more info about the overall process Chronoforms --> vTiger in this link
http://www.digitalbuz.com/2010/02/04/joomla-vtiger-crm-integration-using-chronoforms/)

To understand details of the exact field format requirements for vtiger 5.1.x and 5.2.x, I found the CRM-NOW handbook invaluable:
http://www.vtiger-handbuch.de/DocBooks/manual510/ch002.html#entimpf-ch002


Even though I'm able to make the necessary alterations to any script, my personal recommendation would be to try to utilize other fields in order to store the data.
For example use single radio buttons in your form, rather than the checkbox.

It is quirky and preference should be to use the correct 1:1 scenarion. (checkbox-->checkbox)... but it's a shortcut that saves you from the snag of code mainpulation...which makes future upfrades easier...

..and with that I decide to close this thread, since Chronoform creates an array that can be utilized. But, in this particular case (vTiger) the receiving applikation can handle it correctly.

Regards
Robert O. Akerman
GreyHead 30 Oct, 2010
HI Robert,

Excellent, thank you very much for taking the time to post this.

Bob
This topic is locked and no more replies can be posted.