I am trying to:
Show Repeatable Field Groups of a CTP via REST API
Link to a page where the issue can be seen:
Site under development, in local environment.
I expected to see:
I need to show this Repeatable Field Groups of a CTP via GET request and add some Repeatable Field Groups via POST request via REST API
Instead, I got:
I don't show this Repeatable Field Groups
Hi Marco,
Thank you for waiting while I completed my research.
Based on that, here are my findings:
1. At the moment, there is no direct function available to include custom field data from a repeating field group, in the REST API response.
You're welcome to submit a feature request for this at:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
2. If you'd like to continue using repeating field group fields for your gallery (instead of regular repeating fields), you'll need to extend the response of the REST API using custom code. Here are some useful guides on the topic:
hidden link
https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
To actually get the data from the repeating field group you'll further have two options:
a). You create a post view and set to it return the data from the repeating field group in your desired raw format, for a target post.
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
To get the view's output in your custom PHP code, you can use the "render_view" function:
https://toolset.com/documentation/programmer-reference/views-api/#render_view
OR
b). If you don't want to use a post view for this, you can alternatively use the "toolset_get_related_posts" function to retrieve all the attached repeating field group posts:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
( example usage: https://toolset.com/forums/topic/count-entries-in-repeatable-group/#post-1177647 )
I hope this helps.
regards,
Waqar