Duplicate existing data field
Posted by hamu | On Sunday, 1 September 2013
English
Duplicate existing data field of a content type
- Edit your content type: Go to Structure » Content types . On the MANAGE FIELDS tab, Add new field. Use the same FIELD TYPE as in the field you want to duplicate. Save
- Still in content types: Go to the MANAGE DISPLAY tab, and verify that the new field is visible (it is not displayed under Hidden)
- After the stages above, new database tables will be added: field_data_field_<new field name> and field_revision_field_<new field name>
Put site in maintenance mode and copy old field data to new field's tables:
INSERT INTO field_data_field_<new field> SELECT * FROM field_data_field_<old field name>; INSERT INTO field_revision_field_<new field> SELECT * FROM field_revision_field_<old field name>;
I added org_body field, and copied body field contents to its table:
INSERT INTO field_data_field_org_body SELECT * FROM field_data_body; INSERT INTO field_revision_field_org_body SELECT * FROM field_revision_body;
*The name of the new and old fields can be found in the MANAGE FIELDS tab, on the MACHINE NAME column
Take site out of maintenance mode.