PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to change the type of a field, or replace field without losing data

  1. Here is a situation I just ran into. I created a form which uses a Date type for a field "Member Since". I also made this field "admin only" since the admin will be filling in the date on the back end (this is for entering historical data.) Anyway, the date picker does not show on the back end when you edit an entry, and the helpful "description" text does not appear under the field either.

    So, my user was entering data here as "2009" for example, but the field is looking for date in the format MM/DD/YYYY. With no date picker and no help description when editing the entry in the back end, they complained to me that "their edits were not being saved." Which is true, for this field (even though the confirmation message at the top said "Entry Updated.")

    So, now that I know what the problem is (date being entered with an incorrect format) how can I change this field to just plain text (so the data entered can be almost anything) without losing the data? I don't see a way to change the field type, since that would probably require converting the data in some cases. If I delete the field, I lose the data.

    Any ideas (other than exporting the values for this field from the database, deleting the field, recreating the field in a different type, the importing the data back in to the new field)?

    Posted 14 years ago on Wednesday April 14, 2010 | Permalink
  2. The easiest thing to do will be to change the field type to text (the date field happens to be compatible with the text field, so that should work), but you will have to do that behind the scenes by changing the record in the wp_rg_form_meta table for that form.
    Make sure you back up that table before trying to update that field because it is very sensitive to changes and could get corrupted. If you need help, send me a note to alex[at]rocketgenius.com and I can give you a hand.

    Posted 14 years ago on Wednesday April 14, 2010 | Permalink
  3. I just sent you an email with the dump of the rg_form_meta table. You weren't kidding about it being sensitive. I screwed it up once already. In the email I explained which field I want to change from date to text. Thank you.

    Posted 14 years ago on Wednesday April 14, 2010 | Permalink
  4. The SQL UPDATE statement you sent worked fine. Much easier than any of the solutions I was contemplating. Thanks for the solution.

    Posted 14 years ago on Thursday April 15, 2010 | Permalink
  5. I am glad it worked out Chris.

    Posted 14 years ago on Thursday April 15, 2010 | Permalink