Posted on by

Understanding Possible Data Loss when Changing Field Form Element Type

When a field is defined in Participants Database, it creates a data column in the database table to store the information that field will collect. The way databases work, it’s more efficient to tell it what kind of data you intend to store. So, when a field’s form element is defined, the “datatype” in the database is changed to the best value for that kind of form element.

If you try to change the form element type for a field that has already got data in it, it’s possible to lose some or all of that data. The reason for that is that when the datatype in the database is changed, the type of data it can store is changed. If there is something incompatible in there, it is discarded. For instance, if you had text data stored in a field and you change the field to a numeric type, all that text data would be lost when the datatype changes because what was in there is now incompatible with the new type.

As long as there is no data stored in that field’s column in the database, there is no risk of data loss: there’s nothing to lose. It also won’t ever affect any other columns in the database when the configuration of a field is changed because they’re independent.

How to Avoid Data Loss

If you need to change the form element of a field that has stored data in it, it’s a good idea to have a backup of the database handy. Back up the database before you make any changes like that, and you’ll have a way to restore things if something happens. You can use a CSV export, or a database backup provided by a WordPress plugin. If you do need to use the backup, be sure to return the field to its original configuration before you try to restore the data.

After you change the form element type, check the data in your database. Chances are it will be OK.

In many cases, a good way to go is to just create a new field that has your new type and begin using that field instead. You can leave the old field in there if you want to keep that data. If you’re more adventurous and technically proficient, it is possible to try to get the old data into the new column. In many cases, this won’t work unless you fully understand what kind of data is stored in the new field and you know the old data is compatible or you can convert it to a compatible format. In that case, you can alter a CSV file to import the data from the old field into the new one.

Compatible Field Types

Text Data Type

  • Text Line
  • Text Area
  • Rich Text
  • Checkbox
  • Radio Button
  • Dropdown

Array Data Type

  • Link
  • Multi-Checkbox
  • Multi-Checkbox/Other
  • Multi-Dropdown
  • Multi-Dropdown/Other

Numeric Data Type

  • Date
  • Numeric
  • Currency
  • Decimal

Generally speaking, you can change field types within the column and probably won’t lose data because the new datatype will be compatible with what’s already in there. You should have a backup anyway.

If you have any specific questions about changing the field’s form element and it’s possible effect on the stored data, ask in the support forum.

4 thoughts on “Understanding Possible Data Loss when Changing Field Form Element Type

  1. hi! thanks for you handy plugin. how can i make different lists in this plugin? i mean somthing like contact form 7.
    best regards

    1. It doesn’t work like Contact form 7, you have one database. You can have different kinds of records in the database, but it is still one database.

      Take a look at this for more info:

      ā€œMultiple Databasesā€ with Participants Database

      1. thanks for response. i have two more questions…
        1- there is problem in going through different pages of a list. sometimes it work for one time but it doesn’t work for more. you can check my website toptel.co , how can i fix it?
        2- i use Farsi in my site and after exporting data in csv i see nothing more than weird alphabets. is there anyway that i can fix it?
        tnx

        1. The CSV is exported in UTF-8 which will be OK for Farsi. It is important when you open the CSV that it is encoded as UTF-8

Leave a Reply

Your email address will not be published. Required fields are marked *

Would you like to be notified of followup comments via e-mail? You can also subscribe without commenting.

4 thoughts on “Understanding Possible Data Loss when Changing Field Form Element Type

  1. hi! thanks for you handy plugin. how can i make different lists in this plugin? i mean somthing like contact form 7.
    best regards

    1. It doesn’t work like Contact form 7, you have one database. You can have different kinds of records in the database, but it is still one database.

      Take a look at this for more info:

      ā€œMultiple Databasesā€ with Participants Database

      1. thanks for response. i have two more questions…
        1- there is problem in going through different pages of a list. sometimes it work for one time but it doesn’t work for more. you can check my website toptel.co , how can i fix it?
        2- i use Farsi in my site and after exporting data in csv i see nothing more than weird alphabets. is there anyway that i can fix it?
        tnx

        1. The CSV is exported in UTF-8 which will be OK for Farsi. It is important when you open the CSV that it is encoded as UTF-8

Leave a Reply

Your email address will not be published. Required fields are marked *

Would you like to be notified of followup comments via e-mail? You can also subscribe without commenting.