Home › Toolset Professional Support › [Resolved] Repeatable field
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 22 replies, has 3 voices.
Last updated by quentinN 1 year, 10 months ago.
Assisted by: Nigel.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
That's not quite right.
Yes, drop the table "wp_toolset_relationships" from the database, and Types will recreate it. It occurs to me now that you will also need to drop the tables "wp_toolset_associations" and "wp_toolset_connected_elements" (which will also be recreated).
You will lose any existing records of connected posts (which includes entries in repeatable field groups), but—as I said in my previous reply—I don't see any alternative because of the corruption of the wp_toolset_relationships table.
(I would encourage you to try returning to a prior backup, in case you have one from before the problems with that table arose, but you say this has been happening for months, and that may not be an option.)
You also need to delete the custom field groups which include repeatable field groups and recreate them. Data about custom field groups are stored as posts (post type wp-types-group) in wp_posts, with corresponding entries in wp_postmeta. Because of the problems with the database tables, you cannot delete them using the UI, you must delete them directly in the database.
So, for each custom field group that has repeatable field groups, edit the field group.
Take a note of its ID (from the URL), and take a note of the fields that make up the field group so that you can recreate it manually.
To delete the field group, delete the post with that ID from wp_posts, and delete all entries in wp_postmeta with that ID as post_id.
Do that for each field group that contains repeatable field groups.
Now recreate these deleted field groups. You don't have to redefine the custom fields, when you click the Add New Field button you can then "choose from previously created fields" and you should be able to locate the previous field definitions and use them in the new custom field groups.
(You won't be able to recreate the repeatable field groups, you will essentially be making them as new.)
During the above you won't have deleted the custom field values from your posts. If you set up field groups in the same way as before, re-using your previously created fields, then when you complete the process if you edit a post that uses these fields it should show the field values as if nothing has happened. The different will be the values for repeatable field groups. These are lost and will need to be added again.
Needless to say you should have a backup before you start, and if there is any part of the above you are not sure about, do please ask.
Nigel,
Thank you for your feedback.
I will try the manipulation next Thursday and will keep you informed.
To summarize:
- I make a backup of the DB
- I delete the table "wp_toolset_relationships"
- I delete the table "wp_toolset_associations".
- I delete the table "wp_toolset_connected_elements".
- I delete all the rows of the table "wp_posts" that contain in column "post_type" a repeatable field name
- I recreate in BackOffice the repeatable fields by re-assigning them the classic customs field
- In principle all the pages of the site will keep in memory their values of classic custom fields AND repeatable fields (without having to rewrite them all)
Is this correct ?
Thanks for your help!
Quentin
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Again, that's not quite right.
Deleting the tables, yes.
But it seems like you are confusing custom field groups with repeatable field groups.
Go to Toolset > Custom Fields to see a list of your custom field groups (screenshot).
Some of those field groups contain repeatable groups of fields (e.g. Info Accueil, as shown in the second screenshot).
To clarify, because of the damage to the relationships database table, all of the data from your repeatable field groups is essentially lost; you will need to recreate the definitions of the repeatable field groups, and re-enter the data. (Unless you can restore a backup from before the problem arose.)
You need to go through the list of custom field groups and identify those which include repeatable field groups. Those which do, you need to delete the whole custom field group, and then recreate it. When recreating it, as you add fields to it you can re-use existing field definitions. In that way, the posts which have values for these fields should continue to work inasmuch as that data is still there. But that only applies to the simple fields that are part of the group, not to the fields belonging to repeatable field groups: that data will need to be re-entered.
Here's what I wrote about how to delete the custom field groups that contain repeatable field groups, which are the ones you will need to delete and recreate:
>So, for each custom field group that has repeatable field groups, edit the field group.
>Take a note of its ID (from the URL), and take a note of the fields that make up the field group so that you can recreate it manually.
>To delete the field group, delete the post with that ID from wp_posts, and delete all entries in wp_postmeta with that ID as post_id.
>Do that for each field group that contains repeatable field groups.
Sorry for my misunderstanding, this is a site full of information and I'd like to get it right the first time when I do it.
0 - First of all, I delete the 3 tables "wp_toolset_relationships", "wp_toolset_associations" and "wp_toolset_connected_elements".
I'll now take the example of the page: hidden link
Group of field "Infos Articles" which is displayed on all the articles of the site. (ID_post = 128)
In this BackOffice page, we have 3 repeatable fields (containing simple fields) and 2 simple fields.
- Repeatable field "column-right-1-a" which contains 2 simple fields "insert-label" and "insert-text
- Repeatable field "listing-children-a" which contains 3 single fields ...
- Repeatable fields "column-right-2-a" which contains 2 simple fields ...
1 - I delete in the DB the ID 128 (this line there: SELECT * FROM `wp_posts` WHERE `ID` = 128)
2 - I delete in the DB the lines (there are 6) in response to this request: "SELECT * FROM `wp_postmeta` WHERE `post_id` = 128
2.5 - Should I also delete rows that would contain "column-right-1-a", "listing-children-a" and "column-right-2-a"? and if so, in which table?
3 - I go back to the BackOffice and recreate a new group of fields "Post Info" by recreating the simple fields, the repeatable fields and the simple fields inside the repeatable fields
4 - The first level simple fields should be restored to their original values
5 - The simple fields inside the repeatable fields will have disappeared -> I will have to go through all the pages that used these repeatable fields to refill them manually
Is this correct?
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Yes, that's basically correct.
I have only talked about deleting the settings to register the custom field groups and the repeatable groups of fields, and not about values for the data coming from repeatable groups of fields itself.
I didn't want to complicate the discussion about rescuing your field groups.
To recap, repeatable groups of fields are implemented as posts that are child posts (managed via Types relationships) of the post the groups of fields pertain to.
After you do all the steps described above to rescue your field groups, the database would still contain old data about repeatable field groups, but it would essentially be dead data as it isn't connected to anything.
If you wanted to delete it, you would be deleting the posts (whose post type is the same as the slug of the Repeatable Field Group), as well as the corresponding entries in wp_postmeta for those posts (the field values themselves).
It might be easier to do that with a PHP script.
You would only need to run the script one time, so you could add the following at Toolset > Settings > Custom Code, save it, and then "Run now" to run one time.
(Naturally, you will need to edit the array of RFG slugs, taken from your site.)
// Define an array of the slugs of all of the RFGs $rfgs = array( 'rfg-1-slug', 'rfg-2-slug', 'rfg-3-slug' ); // Get all the rfg posts $rfg_posts = get_posts( array( 'numberposts' => -1, 'post_type' => $rfgs, 'post_status' => 'any' ) ); // Delete the rfg posts (and their post meta) foreach ($rfg_posts as $rfg_post) { wp_delete_post( $rfg_post->id, true ); }
Hello Nigel,
Finally, for security, I duplicated the site.
Me of urgency and of danger thus.
I deleted the 3 tables, delete the ID in wp_post and wp_postmeta.
When I recreate a custom field (attached) I get the error message "The slug is already used."
So I used your snipet to remove the rfg values ... nothing
So I went through the DB to remove these rows directly.. nothing
Still impossible to recreate a group of multiple fields...
So, either you continue to enlighten me on this subject... or it would be possible that I delete all the data of Toolset (total reset) and that I re-fill correctly from the beginning all the fields. I would lose less time than trying our manipulations.
What do you think about it?
Do you have any advice on how to cleanly delete all the Toolset data and all the related rows in the DB?
Thank you always for your help!
Quentin
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
OK, I re-imported the copy of the database of your site I prepared the other day and went through the steps of deleting and then recreating the Custom Field Group Info Accueil, to see if I was missing anything, and I noticed one or two other problems.
First, my own code, I referred to the id (lower case) rather than ID (upper case) which meant it didn't delete the posts associated with the repeatable field groups correctly, and the correct code to use (for this field group, Info Accueil) should be:
// Define an array of the slugs of all of the RFGs $rfgs = array('acces-rapide', 'chiffres-cles'); // Get all the rfg posts $rfg_posts = get_posts( array( 'numberposts' => -1, 'post_type' => $rfgs, 'post_status' => 'any', ) ); // Delete the rfg posts (and their post meta) foreach ($rfg_posts as $rfg_post) { wp_delete_post($rfg_post->ID, true); }
Also the database table wp_toolset_type_sets has the same problem (no unique index or autoincrement) as wp_toolset_relationships, so please delete that table, too. (It will be rebuilt.)
In wp_posts locate and delete the post titled Chiffres Cles (post_name == chiffres-cles, post_type == wp-types-group).
In wp_options locate and delete the option named wpcf-custom-types (which will also be regenerated).
After all of the above I was able to recreate the Info Accueil custom field group, including its repeatable field groups acces-rapide and chiffres-cles, as you can see in the screenshot.
You will need to go through the same to delete and recreate any Custom Field Group that has (had) repeatable field groups.
Thanks, I will try .
That's it, everything works now.
I followed your instructions.
Thank you very much for your follow up and help, it was not an obvious situation.
Quentin