[SOLVED] Form generates unique code

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
CMSmonkey
Power Poster
Power Poster
Posts: 290
Joined: Thu Nov 27, 2008 4:58 pm

[SOLVED] Form generates unique code

Post by CMSmonkey »

Hi Everyone,
I am working with CMSMS 1.6.7 and FormBuilder 0.6.1.  A client wants to have each form submitted generate a unique code.  This code will be used later when a user logs in.  Is this possible?  I know there is a "unique integer (serial)" field, but could this be altered to include additional characters?  For example, instead of responding back "1", can I alter it to respond back "DS1", "DS2", etc.?
Last edited by CMSmonkey on Thu Apr 29, 2010 11:39 pm, edited 1 time in total.
CMSmonkey
Power Poster
Power Poster
Posts: 290
Joined: Thu Nov 27, 2008 4:58 pm

Re: Form generates unique code

Post by CMSmonkey »

Anyone?
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Form generates unique code

Post by Jeff »

this will give you a random number {math equation='rand(10,100)'}
CMSmonkey
Power Poster
Power Poster
Posts: 290
Joined: Thu Nov 27, 2008 4:58 pm

Re: Form generates unique code

Post by CMSmonkey »

ajprog wrote: this will give you a random number {math equation='rand(10,100)'}
Thanks for the response, ajprog.  Where is this entered?  Should I designate it as the value of a hidden field?  And is there anyway I can add some non-numerical characters to it?
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Form generates unique code

Post by Nullig »

I sometimes use the time() as the unique identifier, something like this:

Code: Select all

$reference = "DS" . time();
in a UDT.

Nullig
CMSmonkey
Power Poster
Power Poster
Posts: 290
Joined: Thu Nov 27, 2008 4:58 pm

Re: Form generates unique code

Post by CMSmonkey »

Nullig wrote: I sometimes use the time() as the unique identifier, something like this:

Code: Select all

$reference = "DS" . time();
in a UDT.

Nullig
Awesome!  That works great!
CMSmonkey
Power Poster
Power Poster
Posts: 290
Joined: Thu Nov 27, 2008 4:58 pm

Re: Form generates unique code

Post by CMSmonkey »

Thought it was solved... but I guess it wasn't. 

This works great in a UDT -- but how do I get it to be the value of a field?
CMSmonkey
Power Poster
Power Poster
Posts: 290
Joined: Thu Nov 27, 2008 4:58 pm

Re: Form generates unique code

Post by CMSmonkey »

Yeah! I got it to work!

For anyone else who wants to know...

I created a UDT and called it ref with the following code:

Code: Select all

global $gCms;
$smarty = &$gCms->GetSmarty();
$reference = "DS" . time();
$smarty->assign('reference', $reference);
On the page where the form is to be called, I added {ref} into the content section.

On the form, I created a hidden field, put {$reference} in as the value, and checked off "process smarty tags" on the Advanced Settings page of the field settings.

Thank you Nullig for the suggestion.
Post Reply

Return to “Modules/Add-Ons”