cforms II User Forum

Registration is currently disabled.
Guest

FAQs

Login form protected by Login LockDown.


Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
my_cforms_logic - syntax for $cformsdata
January 11, 2009
12:27 am
Ted
Guest

uri=local(development); browser=firefox2;wp=2.7; my-function.php is in plugins/cforms folder.

I need help understanding the syntax for $cformsdata.

I have a form (say #9) that is part of a multipage form; "next form after this" = form#10. Among other things, form#9 is used to select a 'Diary size' using radio buttons – the options are A5, B5 and A4. Depending on chosen diary size, I want to change the next form to form#11 or form#14 (or leave as form#10). BTW in the table "wp_cformsdata", the field_val for field_name = "Diary Size" is = "A5"or "B5"or"A4".

I've tried several alternatives based on "if ( $setting == "nextForm"){:
if ( $oldvalue=='10' && $cformsdata['data']['cf9_field_4-3'] == 'checked') return 14;}
if ( $oldvalue=='10' && $cformsdata['data']['diary size'] == 'A4') return 14;}
if ( $oldvalue=='10' && $cformsdata['data']['cf9_field_4']=='A5' ) return 10;}
if ( $oldvalue=='10' && $cformsdata['data']['cf9_field_4-3'][checked] == 'yes') return 14;}
if ( $oldvalue=='10' && $cformsdata['data']['Diary size']=='A4' ) return 14;

None of these work. Can you assist please?

January 11, 2009
1:02 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

If uncertain about how to access the data array and the structure of it, have cforms send you a test mail (the below example is in the file under my_cforms_action()):

@mail('your@email.com', 'cforms my_action test', print_r($cformsdata,1), 'From: your@blog.com');

PS: Generally, v10.1 will be released soon that'll fix some MP feature issues (however this is not connected to the above).

January 14, 2009
2:49 am
Ted
Guest

Maybe I have misunderstood the purpose and functioning of 'my-functions.php'.

I tested cforms.php at line 249- does the 'logic' function exist?  It evaluates to 'no'.

Tested putting the logic function directly into cforms.php – everything runs like clockwork.

Obviously I am missing something here; and probably pretty basic too. :(

Suggestions?

January 14, 2009
7:27 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

did you uncomment the logic function in my-functions.php?

by default *all* functions are commented out:

/*

*/

January 14, 2009
9:19 am
Ted
Guest

Well, I DID say it was something pretty basic <grin>.

Me bad. I saw the uncomment reference but it didn't occur to me that all the functions were commented out.

Many thanks.

Ted

January 16, 2009
5:08 am
Ted
Guest

The function works perfect when cformsdata is on the current form. But if the data criteria refers to a page prior to the current page then the function doesn't work. Perhaps this is because it relies on trackf.

Example: page1 of a multi-page form has a data field called 'size'.
Say, I have completed page 1, page 2, and page 3 in the multi-page form.
Now I want to branch depending on the value of "size" in page1.
As I see it, the normal syntax doesn't work because it will only 'look' at the cformsdata from page 3.

Am I missing something?

January 16, 2009
7:17 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

yes, if you need to access data from a previous multi-part form, you need to access the $_SESSION array, that's where all the data is stored meanwhile.

for testing/understanding you might want to print out the array structure, just add a:

echo '<pre>'.print_r($_SESSION,1).'<pre>';

January 17, 2009
1:06 am
Ted
Guest

<thud> = sound of head hitting desk.

Of course! Changed  "cformsdata" criteria to "$_SESSION['cforms']blah.." and worked a treat.

Thank you

October 5, 2012
12:32 am
Barry
Guest

I'm so glad I found this thread!  I've been struggling for over a day to get a conditional multipage form working, whereby the next page you jump to is dependent on data that you entered on a previous page.  I did the echo '<pre>'.print_r($_SESSION,1).'<pre>' thing as a debug aid to see how to access the values in the $_SESSION array, set up the if statements, and it works great.  Being forced to learn PHP, too. sf-wink

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

tracedef: 43

mores: 21

Gyrus: 20

frozenwaste: 18

asuffredini: 15

photoworks: 14

Member Stats:

Guest Posters: 3762

Members: 1463

Moderators: 3

Admins: 2

Forum Stats:

Groups: 1

Forums: 4

Topics: 5361

Posts: 18742

Newest Members: juredujmovic, dreamkeeper, rajattyagi, wrokaa, lukass

Moderators: Paul (421), cnymike (8), sonika (95)

Administrators: Oliver (6400), Nicky (3)