Convert a custom field from Tag field type to Checkbox or Select Multiple field type
Although you can change a custom field's field type from Tag to Checkbox, doing so directly from Mosets Tree's back-end UI may not be ideal due to the way data is stored in Tag and Checkbox field type. It may cause data loss when you or your users save their listings.
The following steps let you perform the conversion safely, without data loss:
- Create a new custom field based on Checkbox and note its custom field ID. In this example, let say the custom field ID is 100. Also note down the custom field ID of your existing Tag custom field. Again, as an example, we assume this is 90.
Edit the new Checkbox field and populate its Elements input box with all possible values your users will enter. The tricky part here is knowing what your users has already entered and make sure that value is available as elements too. If a value that has been entered by your user but not in the list of elements, the value will be lost when users save their listing in the future.
Each elements are separated by the bar character |.
If you have access to MySQL or phpMyAdmin, you can perform the following query to return all values saved by your users, so that you know what to populate in the Elements box:
SELECT * FROM
Note: replace jos_ with the database table prefix your site uses.
Now that you have the new Checkbox field ready, it's time to copy the data from your existing Tag custom field to it. Run the following SQL query:
INSERT INTO jos_mt_cfvalues (`cf_id`, `link_id`, `value`) SELECT '100', `link_id`, REPLACE(REPLACE(`value`,', ',','),',','|') FROM jos_mt_cfvalues WHERE `cf_id` = 90;
Once you've perform the steps above, test the new Checkbox field to make sure the values are properly converted from your Tag field. You can then unpublish and eventually remove the old Tag custom field.
The steps above is applicable to converting your custom fields from Tag field type to Checkbox or Select Multiple.