auto populate a text field when creating a new record?

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 21, 2012   (RSS)

By gord - January 21, 2012

Hi,

I'm building a system to enable downloads via a combination of random strings. Basically users will each be assigned a random string, and the files will likewise be assigned a random string. To download their file, the user will enter a string that consists of the two. So far so good, but as I've already got cmsBuilder on my site, I'd like to use it to deploy this system too.

I am trying to figure out the best way of assigning the random strings. Is there a way cmsBuilder can automatically populate a text field in a new record by somehow calling a custom routine (that I would write) that would generate the string?

If not, does anyone else have other ideas about how to implement this?

Thanks,
gord

Re: [Dave] auto populate a text field when creating a new record?

By gord - January 21, 2012 - edited: January 21, 2012

Hi Dave,

Thanks so much - this is more or less exactly what I was thinking. It just didn't occur to me I could embed php directly into the default value field like that!

What would the be the best way to include a custom function, short of pasting it all into the default value field? Will I have a problem by modifying the admin.php file to include my own function(s)?

Thanks again!

Re: [gord] auto populate a text field when creating a new record?

By Dave - January 21, 2012

Hi Gord,

Probably the easiest way to include a custom function would be with something like this:
<?php include "/path/to/your/custom/file.php"; ?>

Avoid modifying the program files if you can because if you want to upgrade later your changes might get overwritten.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com