Forums

Returning cf_id for use as a reference number

Trouble 09 Apr, 2011
First off, wow! Thanks for ChronoForms 4! It's really really good! We're a charity who has no budget for a web site and ChronoForms 4 is every bit as good as the commercials solutions I've seen!

Now my question.

I've made a booking form, and need to attach a booking reference id to the resulting e-mail and in the thank you message on screen. As cf_id in the database table is unique I would like to grab this.

I've tried various bits of PHP code in the e-mail template, but to no avail.

I found a forum topic on the subject for pre-ChronoForms 4, but the solution doesn't work in ChronoForms 4 for Joomla! 1.6.

Can anyone help?
Many thanks!
GreyHead 09 Apr, 2011
Hi Trouble,

I think that all the data saved should be available after the DB Save Event in the $form->data['chronoform_data'] object*

You should then be able to access the id with something like:
<?php
$data = $form->data['chronoform_data'];
echo "the id is ".$data->cf_id;
?>


Bob

* 'chronoform_data' is the default value unless you change it in he DB Save configuration.
Trouble 09 Apr, 2011
Thanks Bob!

Unfortunately that doesn't work :-(
All I get is "the id is ".

I've come from a J 1.5 upgrade and put the data in to it's own table so I confirmed the table name in phpMyAdmin and changed the code to:

<php
$data = $form->data['j16_chronoforms_data_booking_enquiry'];
echo "the id is ".$data->cf_id;
?>


It's in the template section of the "Email - #1" event, which appears straight after the "DB Save" event.

Justin
GreyHead 09 Apr, 2011
Hi Justin,

You don't want the table name in there (unlike CFv3.2). There's a new Model ID set in the DB Save configuration.

Do you have a cf_id column in your table?

Bob
Trouble 09 Apr, 2011
Hi Bob!

Ahh yes I see.

The Model ID in the DB Save configuration is still the default "chronoform_data"!

I definitely have a cf_id column.

Although I have copied and pasted your code it still returns just "the id is ". :-(

Many thanks!
Justin
GreyHead 09 Apr, 2011
Hi Justin,

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
Trouble 09 Apr, 2011
Bob, your reputation precedes you🙂

URL and login e-mailed.

Thanks once again!
Justin
GreyHead 09 Apr, 2011
Hi Justin,

A little trial and error - apologies for all the emails you had to delete - but we got there in the end. The data is in an array not an object and the code needed is
<?php
$data = $form->data['chronoform_data'];
echo "the id is ".$data['cf_id'];
?>

Bob
Trouble 09 Apr, 2011
Bob... THANK YOU SO MUCH!!

You really are a legend!

Thanks again!
Justin
This topic is locked and no more replies can be posted.