Support » Plugin: Participants Database » Changing Field Form Element Type

  • MarionFW


    I’ve got a hidden field that contains dates in format dd-mm-yyyy.
    I’d like to change that to a regular date field.

    Has anyone tried this before and avoided data loss?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author xnau webdesign


    You won’t be able to change that because a date field stores it’s value as a unix timestamp, and the data type is numeric, so date strings such as what you have there will be deleted when the datatype is changed.

    There are several ways to make this change without losing data, and what I would recommend you do first is to create a new field that is a date field which will hold the converted data and eventually replace the field you have now.

    Then you can make the conversion by exporting to a spreadsheet that is set up to do the conversion. Or, if you’re good with mysql, the best way to do it is directly in the database with a custom query.



    Thanks for giving some further explanation. Just one more question: is this possible:
    * make a new field ‘temp’
    * fill it with the information from the old field
    * delete the old field
    * rename the ‘temp’ field so that it has exactly the name the deleted field had

    In that way, I could avoid having tot check / change the lists on the front end.

    Plugin Author xnau webdesign


    You can do something like that, but slightly different:

    1. create a temp field (text-line)
    2. copy the data from the original field into the new temp field
    3. switch the old field to be a date field
    4. convert the data in the temp field to Unix timestamps and store that back in the old field
    5. delete temp field

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Changing Field Form Element Type’ is closed to new replies.