Is there a way to directly get the value of a group sub-field.
For example, I have a Group field my_options (field_abcde), and inside that field I have an title field (field_12345).
I tried using get_field(field_12345, 'option') in order to get the title value directly, but that’s not working. It seems that the values are only saved in the “root” field.
I know there are simpler workarounds, but my real use case is more complicated. But if you are curious about my real use case:
I want to build a custom ACF Field that will let admin’s have a “select” field that’s populated with all the repeater type fields in the options field group. For example, an Admin creates a list of approved images using a repeater field in the “Site Options” page, then using this custom ACF Field it adds an image field to a block field group, so that Editors can add a block in the admin and choose from the approved list of images.
Thank you both for your help. Using the field names concatenated with an _ worked great.
Unfortunately, I am going to stick with the more inefficient method of fetching the group value and traversing into the individual value using loops, since I feel more comfortable storing ‘field keys’ since they are less likely to change than ‘field names’.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users