Are there any other fields that work this way?
Looks like this shortcut of combining parent and child field names with _
is specific to the Group field type.
The Group field uses both the parent and child field names when saving and loading values. For example, a Group field named ‘hero’ with a sub field named ‘image’ will be saved to the database using the meta name ‘hero_image’.
From: ACF | Group
(It might have been better to use double underscores __
to avoid any possible conflict with parent/child fields that include _
in them already. For example, a field called book_author
might conflict with a parent field called book
with child field author
.)
But the Field
tag itself has a shortcut for accessing a subfield. It can be seen in some of the field type examples, like:
<Field acf_file=field_name field=title />
<Field acf_image=field_name field=url />
I haven’t tried it, but it looks like it may work with the Group field type.
<Field acf_group=group_field_name field=sub_field_name />
This shortcut syntax wouldn’t work for repeater or flexible content, because those field types can have more than one child field. Theoretically we could add a field_index
attribute to make that possible.