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.?
[SOLVED] Form generates unique code
[SOLVED] Form generates unique code
Last edited by CMSmonkey on Thu Apr 29, 2010 11:39 pm, edited 1 time in total.
Re: Form generates unique code
Anyone?
Re: Form generates unique code
this will give you a random number {math equation='rand(10,100)'}
Re: Form generates unique code
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?ajprog wrote: this will give you a random number {math equation='rand(10,100)'}
Re: Form generates unique code
I sometimes use the time() as the unique identifier, something like this:
in a UDT.
Nullig
Code: Select all
$reference = "DS" . time();
Nullig
Re: Form generates unique code
Awesome! That works great!Nullig wrote: I sometimes use the time() as the unique identifier, something like this:
in a UDT.Code: Select all
$reference = "DS" . time();
Nullig
Re: Form generates unique code
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?
This works great in a UDT -- but how do I get it to be the value of a field?
Re: Form generates unique code
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:
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.
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 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.