Buy Now
Sign in

Need help with concatenating form fields to save in database

4Summit , July 21 2017
4
4Summit
Hi,
I have a simple form that has name and 3 drop downs for year, month, and day for user date of birth. I want to concatenate the 3 values into a dob form value and only save name and dob in the database.

1) Based on the manual and other postings, i created the following custom code for dob (which is a hidden field in the form). i am not able to get the concatenation to work. What am I doing wrong?

var dbirth = {data:year}."-".{data:month}."-".{data:day};
{data.set:dob,dbirth};

Debugger O/P:

Array
(
[option] => com_chronoforms6
[chronoform] => user_registration
[event] => submit
[first_name] => Test
[last_name] => Again
[month] => 1
[day] => 1
[year] => 1975
[dob] =>
[Submit] =>
[Itemid] =>
[dob,dbirth] =>
)


2) How can I save just name and dob in the database? I provided {data:first name}, {data:last name}, {data:dob} in the data provider field, no columns get updated. If I just have {data:}, then all fields get updated (which I don;t want).

I am guessing the syntax for data provider is not right and i could find a working example anywhere. Please help.
admin
Hi 4Summit,

Leave the data provider set to {data:} but in the "Data override" use the following:

name:{data:first_name} {data:last_name}
dob:{data:year}-{data:month}-{data:day}


Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
P
paula_ga
Hi,
I need to do something similar. ​
​Could you please tell me where to I write the following code?​
​​
​title:{data:title} {data:first_name} {data:last_name}​
​​
​Thank you very much for ansewring me.
admin
Hi Paula,
This is for saving the data into the table, if your table has a field named "title" then you place that code in the "insert data override" box in the "Save data" settings
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!