Hello!
I have added checkbox option to my form.
Now I need to show results in table.
Which table data option ("varchar" or "tinyint" or any other) should I use to add the checkbox form results to table?
Thanks,
Raivis
Hi Raivis,
TINYINT if the value being returned is an integer. VARCHAR if it's a string. If in doubt use VARCHAR.
Bob
PS You need to refresh the DB Connection after any changes to database column names. In the Form Editor click the DB Connection tab and set the Connection to 'No'. Click the 'Apply icon in the toolbar to save the form, open the DB Connection tab, set the Connection back to 'Yes' and re-save the form. This will refresh the copy of the table information that ChronoForms uses.
Thanks Bob,
I'll check!
Brgds,
Raivis
Hi Bob,
Unfortunately I could not manage to get data into table..
Form contains two input fields: email and checkbox (with 3 options to choose to check).
Email is formed like text field and it works ok. Data (email address) gets into table.
Also email verification link function gets into table, with "1" or "0" data respectively.
But checkbox data dont. I have disabled and again enabled table connection as I always do.
What could be the issue?
AutoGenerated Code shows that the field name for checkbox option should be "check0" and I have added "check0" data field name with varchar option to table but it stays empty (with no any data).
If I check for the name field in FormCode html then I find it as "check0[]".
So I try to find the reason why there is no data for checkbox in table but can not so far..
Any suggestions?
Let me know if you would like to see codes..
Thanks,
Raivis
Hi Raivis,
If you use an array name (like check0[]) for the checkbox then set "ChronoForms handle my posted arrays" to 'Yes'
Bob
Hi Bob,
It was already set to "Yes".
By the way, if I try to add field name in table as check0[] the system does not allow to do it and says "alphanumeric characters or underscore"..
So I can not be sure if I should use "check0" as Autogenerated Code shows, or should I use "check0[]" as I find it FormCode (but system does not allow this option to be inserted into table).
I also have tried to use field names as check00 and check01 and check02 as there are three checkbox options in form. It also does not work..
Confused... Although tried to find it out myself very carefully...
Suggestions?
Brgds,
Raivis
Hi all,
Looks I found the problem.
I renamed the name fields in Form Code HTML so that they do not contain square brackets.
Now I am able to write correct name field into table (alphanumeric and underscore characters allowed only) and data gets into table.
Brgds,
Raivis
Hi Raivis,
If you have a group of checkboxes in your form you use the array name xxx[] (with square brackets) to link the results together. Then you use the same name without the square brackets in the table, template etc.
The ChronoForms array handler will manage the conversion from an array to a comma separated string for you if it is turned on.
If there's only a sinlge check-box then you don't need the array name.
Bob
I had the same problem as raivis had, and i fixed it as he said, removing the [] after the checkbox name,
Hello,
Maybe I am missing something here, but is there any way I can post CHECKBOX DATA into a table as 0 or 1?
If I use tinyint I always obtain a 0 into the database.
Can you please point some directions here?
Thank you!
DINO
Hi Dino,
I've not tried but I think that if your Checkbox values are 0 or 1 then they should save correctly.
BUT Checkboxes usually come in groups and return an array of results not just one so what is in the $_POST results from your form?
Bob
Hi Bob,
Thank you for your reply and please accept my apologies for opening a new thread with the same problem.
Your idea was very good. I have used TyniInt as field type in the database, but If I use varchar and set the default value to 0 and each checkbox value as 1 then it's working.
I will just change all my field types to varchar.
Thank you again!