Forums

Custom Variables for Database Injection [HINT!]

Gekko23 12 Jan, 2009
Hi folks!

After trying out a lot of different approaches, here's my final working scheme for inserting custom variables into the database.

Problem:
my ChronoForms form is very generic, it is used on different locations on the site with different objects to handle. when the {chronoforms} is called, many information is still unclear, but these variables get filled through calculations and queries before sending an email. But despite of having declared some of them to get gathered for being injected into database records of the form, all these variables did appear in all calculations and dialogues, but they did not get into the database.

Solution:
1.) If it's clear which variables should be recorded, simply add them as a hidden field into the form, e.g.:
input value="" id="custom" name="MyCustomVariableA" type="hidden">

Repeat this with EVERY VARIABLE that should be recorded

2.) create the database table in "Forms Management". ChronoForms looks into the form and lists all the hidden entries for you. Check every variable you want to record.
Save the table.
Enter the form, move to the "DB Connection" tab, select your newly created database table and SAVE.

3.) Now DELETE every
input value="SEARCHME" id="custom" name="MyCustomVariableA" type="hidden">
in the forms HTML tab (if they are NOT filled with values through the form by the user as it was in my case). Fill them through queries or calculations, just the way you want them to be created.

4.) In the "On Submit code - before sending email" tab you can hand over the values to be recognized by ChronoForms by just entering the following line for any of your calculated/queried value:
JRequest::setVar('MyCustomVariableA', $JustAnExampleValueThroughAQuery->displayname, 'post');

By doing this, your "MyCustomVariableA" will be injected into the form record and your form doesn't handle any useless code. "displayname" is just an example.

It took me some time to figure this out, so i hope, it can help somebody.

Big Cheers,
Gekko =)
Max_admin 12 Jan, 2009
Thanks for sharing the hints!🙂

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.