Forums

Auto number, possible?

pinobird 13 Jun, 2009
Hi all,

I lover to work with CF and was wondering if it's possible to add a field that automaticly generates an number depending on the number of times the form has been used. This fiels must be send by mail to the sender as well as the responder.

I hope someone can help.

Hans
GreyHead 14 Jun, 2009
Hi Hans,

Probably the easiest way to do this is to save the form results to a database table and use the record_id as your counter.

You'll need to switch the Autogeneratdd code to 'Before Emails' to make this work OK.

Bob
pinobird 15 Jun, 2009
Bob,

Thansk for your suggestions. However, i'm not that familiar with databases. I hoped it was possible by adding a simple visible autogenerated number field to the form.

I need this because the submitter (who receives a copy of his/her submission) has to use this number as his/her reference number.

Greetings,

Hans
Max_admin 16 Jun, 2009
Hi Hans,

in your onSubmit before email use this code:


<?php
JRequest::setVar('autonum', $MyForm->tablerow["table_name"]->uid);//change table_name to your real table name
?>


in your email template use :

{autonum}

Cheers
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
junfpurba 28 Mar, 2012
Hi,

I have try the code,but in email display {autonum}
the code doesn't work in CF v3 ?
GreyHead 28 Mar, 2012
Hi juna,

Yes this was CFv3 code but it's an old post. What do you need to do?

Bob
junfpurba 28 Mar, 2012
Thanks for your suggestion

I have a succes to save form data to database. and I has create 1 field dep_id in my table and this is Auto Increments.

I need dep_id send by email to subsciber

how I make it?

thanks
GreyHead 28 Mar, 2012
Hi juna,

ChronoForms saves the database record in the $form->data array so that you can recover the new id. Drag a Debugger action into the ON Submit event to see the data available.

Bob
junfpurba 28 Mar, 2012
Hi GreyHead,

how to Drag Debugger ?
is this some feature of CF?

or this is not work on CFv3 ?

thanks
GreyHead 28 Mar, 2012
Hi Juna,

Sorry, I was confused, if you are using CFv3 then the code Max posted should work OK but you have to get the sequence correct. See this post for more info.

Bob
junfpurba 28 Mar, 2012
Hi GreyHead,

sory about make u confused.
I have try the code form the post

<?php
$MyForm =& CFChronoForm::getInstance('FormIsiPulsa');
$autonum = $MyForm->tablerow['deposit']->dep_id;
echo $autonum;
?>


but I have output like this:
Fatal error: Class 'CFChronoForm' not found in /home/mask/public_html/components/com_chronocontact/chronocontact.php(600) : eval()'d code on line 2

Can u give me a code for CFv3 ?

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