Forums

Guidance on selecting field types and sizes

KarelMG 19 Sep, 2012
Is there some guidance on selecting field types when creating a database?
For example I want to use a Checkbox Group, but I don't have a clue on what field type and size to select.
GreyHead 20 Sep, 2012
Hi KarelMG,

If your form is small then you can probably use the ChronoForms default settings which are VARCHAR(256) for most form inputs. The one exception is textarea elements where you should probably choose the TEXT type unless you know the maximum length that will be posted. For instance a VARCHAR(256) will only allow 256 characters.

If your form is long then you need to know that there is a limit to the maximum number of characters in a MySQL record of 65,535 bytes. This sounds a lot but note that UTF characters take 3 bytes so there is a maximum of around 80 columns of type VARCHAR(256).

If you need to tune your record then you should use the shortest 'safe' type for each column. So a 0/1 boolean value can go in a type BOOL; a date in a type DATE or DATETIME, a short integer in a MEDIUMINT, etc.

Strings are usually best in type VARCHAR: VARCHAR(16) is OK for a single name; VARCHAR(32) for a first and last name); VARCHAR(64) for an email and probably an URL; and so on.

There's more information on the various types in the MySQL manual here.

Bob
KarelMG 20 Sep, 2012
Dear Bob,

Maybe my question was too generic.
My specific problem is that I don't know which field type is to be used for a Checkbox group. I have tried ENUM and SET, but in both cases nothing is stored to the database. In the values field I have entered the values as mentioned for the different options.
I hope you have some guidance on the use of a Checkbox group.

Regards,

Karel
GreyHead 20 Sep, 2012
Hi Karel,

Use a Handle Arrays action to convert the result array to a string. Then set the VARCHAR long enough to handle the longest possible string i.e. when all the boxes are checked.

Bob
KarelMG 20 Sep, 2012
Thanks Bob,

Indeed this fixes my problem, but it brings me immediately to the next problem. The check marks in the boxes are not shown anymore when I reload the form. I want my registered users to give the opportunity to change their inputs.

Regards,

Karel
GreyHead 20 Sep, 2012
Hi KarelMG,

There was a bug with this but I thought that Max had fixed it in the latest release. Which version of CF are you using?

Bob
KarelMG 21 Sep, 2012
Hi Bob,

I'm using Chronoforms_V4_RC3.4.1_J1.6.

It seems that check marks are showing at random when reloading the form.

Karel
GreyHead 21 Sep, 2012
Hi KarelMG,

Please upgrade to CFv4 RC3.5 which is the latest version.

Bob
KarelMG 21 Sep, 2012
Hi Bob,

I've upgraded to the latest version, but this is not the solution.

Karel
GreyHead 21 Sep, 2012
Hi Karel,

Please drag a Debugger action into the On Submit event and post a link to the form so I can take a quick look.

Note: if you are using the Easy Wizard you can turn on the Debugger on the Other tab.

Bob
KarelMG 21 Sep, 2012
Hi Bob,

I'm running a try-out website on a local XAMPP server, so I can't give you access.
Anyhow I've made a file of the debugger result. Is this enough for you?

If you really need access to the form I have to include the form in my life website, but this takes some time since I have to rebuild the form there.

Karel
GreyHead 21 Sep, 2012
Hi Karel,

That all looks OK, not sure why you are having problems with the checkboxes :-(

Maybe Max hasn't fixed the bug.

When do the errors occur, when there is an validation error on submitting the form or when you re-load a record to edit it.

Bob

PS You can move forms between site using the Form Backup and Restore icons in the Forms Manager Toolbar.
KarelMG 02 Nov, 2012
Hi Bob,

After some holidays I'm picking up the development of my site again.

Do you know whether Max already fixed the problem with reloading of the checkboxes?

Kind Regards,

Karel
GreyHead 04 Nov, 2012
Hi Karel,

I believe it was fixed in 3.5

Bob
KarelMG 05 Nov, 2012
Hi Bob,

Like I already reported on Fri Sep 21, I have upgraded to v3.5, but the problem still exsists.

Best Regards,

Karel
GreyHead 05 Nov, 2012
Hi Karel,

Sorry, I'm travelling this week so only dipping in here. If 3.5.1 doesn't fix it please contact Max using the Contact Us link above.

Bob
This topic is locked and no more replies can be posted.