[Gelöst] Is there a way to default repeating fields as expanded instead of collapsed?
This support ticket is created vor 6 Jahren, 5 Monaten. There's a good chance that you are reading advice that it now obsolete.
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
When a user opens a CPT on the back-end and their is a custom repeating field that has values already input, is there a way to default those fields to be expanded instead of collapsed?
No, but I may be able to point you in the direction of a JS snippet that would do the job.
Before I look into that, though, I'm not sure why you are using repeatable field groups rather than simple repeating fields.
It looks like you are letting users add multiple phone numbers and multiple email addresses to a post.
You would use repeatable field groups when you some of the field values were connected with each other.
For example, you might add multiple contacts to a post, and for each contact you would provide a name, email address and phone number. So you create a repeatable field group for contacts which includes fields for email and for phone.
In your case it looks like your repeatable field groups contain just one field, for which you can just use simple fields where you can add multiple instances of the field, so you can add as many phone numbers are required, and as many email addresses as required.
If that's the case you can change to using repeating fields and then your question no longer applies.
Ok, I wasn't aware of that. I bet there isn't an easy way to convert from the repeating field groups to simple repeating fields without loosing the data I have in those fields???
Custom fields are stored in wp_postmeta against the post they belong to.
But with RFGs a post is created for each instance of a repeating field group to act as a container for the fields, so the fields themselves are still stored in wp_postmeta but against the container post, not the original post.
So to convert them would mean running a script that loops over all of the RFG posts and then updates the post meta for the post to which the RFG belongs using the post meta from the RFG post.
Ok, I will leave as is. Thanks for your help. For the future, maybe if there is a post/tutorial on the differences between a repeating field and a repeating field group and when to use one versus the other would be helpful to users.