My CFv5 form data isn't saving to the database correctly

ChronoForms will automatically save data to a database table if you have added a DB Save action (or actions) to the form On Submit event. Here is a useful checklist:
If the database table has 'id' as the Primary Key then you may get errors when you show the form in an article. This is because the article id shows in the page URL, ChronoForms will save this with the form data and then try to update the record with that id. Either it will not exist and the save fails, or if it does exist then the already saved record will be updated instead of a new record being created.
There are two ways to resolve this:
  • Rename the Primary key column in the table to e.g. cf_id
  • Add a Custom Code action before the DB Save action to unset the value taken from the URL using the code below.
<?php
unset($form->data['id']);
?>
If that is not the problem you are seeing please check the following:

The DB Save action has been added to the form and is configured to save to the correct table.

The table has a numeric primary key (it will if you used the ChronoForms 'Create table' icon). It must be an integer and not a string.

If you have added or renamed any columns in the database table, please click the 'Clear cache' icon in the Forms Manager toolbar to update CF's records.

The form input names you want to save match the table column names **exactly**

None of the input or column names contain spaces, dashes, or other special characters except for underscore '_'

The input and column names all start with a letter.

Any array data from a Checkbox Group or a Multi-Select dropdown has been converted to a string. Use a Handle Arrays action before the DB Save action to do this.

If you are using a Model ID then make sure that all the data is stored in the correct sub-array of $form->data for example $form->data['my_model_id']

 
 
 

VPS & Email Hosting 20% discount
hostinger