Buy Now
Sign in

HELP: multifield form

aki76 , October 30 2012
A
aki76
Hi,
I need a "little" help. I searched throu the web but I didn't find anything.

I must build a form to collect subscription to an event (i.e: a Marathon). In this form, the single user can subscribe himself inserting name, surname, gender, town, year of birth (and there is no problem for this case) but a team can subscribe once the form. In this case, I can insert the team name, town, but I must insert 1, 4, 10... name, surname, gender and year: one for each person (and I can't know how many they will be!).
I thought to have a single row (name, surname, gendere, year) and a [+] botton, clicking on it another row will be created automatically.
At the end, I have to save data on db, one row for each person.

Can anyone tell me if Chronoforms can do this?
The version is 4.0 RC3.5.1 on J 2.5.

Thank you!
Kind regards
GreyHead
Hi aki76,

Please look at this post and the other posts in that thread. Is this doing what you want?

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
aki76
Wow! An answer from the guru of Chronoforms!
Thank you, it's exactly what I was seraching for! Now I try to build it myself with your code and to insert data in table... if I have problems I'll ask you

Thank you very much
Aki76
A
aki76
Here I am

I take the script, but I have a js error (null is null or is not an object - mootools-core.js line 294).

The line of your script that generate the error is

div.inject($('add_here'));

Have you any suggestions? :?
Thanks!
Aki76
GreyHead
Hi aki76,

Do you have a div with the id='add_here' in your form? If you do then probably div is undefined for some reason.

Please post a link to the form so I can take a quick look.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
aki76
:shock: no I had not!
Now I added it and seems work... thank you!
Aki76
A
aki76
Hi! I put in stand by this work but now I'm working again at this project...
I did the form, it works.

Now I'm trying to save the data, and I did'nt find tutorials or helps... debug result is:

Data Array: 
Array
(
[chronoform] => frmName
[event] => submit
[format] => html
[Itemid] => 129
[option] => com_content
[view] => article
[id] => 14
[groupname] => aaa
[surname] => aaa
[name] => aaa
[year] => 1976
[phone] => 111
[email] => aa@aa.aa
[gender] => M
[town] => mytown
[surname1] => bbb
[name1] => bbb
[year1] => 1977
[phone1] => 222
[email1] => bb@bb.bb
[gender1] => F
[town1] => anotherTown
)


Fields from "groupname" to "town" are correctly saved on the table I did for this form. Now I want to save the fields from "surname1" to "town1" too (and, if I add 5 rows to the form, the 5 rows too) in a new db row. The field "groupname" is the same for every row.
I think I must use Model ID on DB Save but I can't find a tutorial that can help me in this :-(

Someone (GreyHead? ) can tell me where can I search?
Thanks a lot!
Aki76
GreyHead
Hi aki76,

There was another thread about this recently. You can't do this using the DB Save action. The simplest answer is to hand-code the MySQL query to save multiple records to the same table and add that to a Custom Code action.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
aki76
Hi GreyHead,
thank you!

While I was waiting for an answer I tried to modify the db_save.php file... and I succeded in! I know it's very deprecated and not recommended to modify core files 'cause they will be overwrite in case of updates... but now I can take this code and put it into a custom code as you say.

Thank you very much!
Aki76
A
aki76
After about 1 year (because of requested updates to the form I built with the precious help of GreyHead 8) ) I need another help.
I use this code to create - in loadJS - a select field:
label = new Element('label', {
For: 'myfield' + m_count,
text: 'Register? '
});
label.inject(div);

lep = new Element('select', {
name: 'reg' + m_count,
id: 'reg' + m_count,
Class: "validate['required']"
});
lep.options[0]=new Option(" ", "");
lep.options[1]=new Option("No, thanks", "0");
lep.options[2]=new Option("+ € 1,00 - Base Registration", "1");
lep.options[3]=new Option("+ € 3,00 = 1 year!", "3");
lep.options[4]=new Option("+ € 6,00 = 2 years!", "6");
formCheck.register(lep);
lep.inject(div);


I wish to have 1 optgroup, to replicate this:
<select name="reg" id="reg">
<option value=""></option>
<option value="0">No, thanks</option>
<optgroup label="Yes, please!">
<option value="1">Base Registration</option>
<option value="3">+ € 3,00 = 1 year</option>
<option value="6">+ € 6,00 = 2 years</option>
</optgroup>
</select>


I can't succeeded in insert optgroup... anyone can help me please?
Thanks,
Aki76