Skip to content

Clone Field placed within a Group Field returns null values #184

@mandytensen

Description

@mandytensen

Description

When using the Clone field type nested inside of the Group field type, all values from the cloned fields return null instead of returning expected data.

This “Clone within a Group” is a pattern our team uses quite a frequently. We have field groups containing small collections of fields. These small collections are often included in various other larger field groups via the Clone field. And for organization (be it for authoring or code), we place these Clones within Group fields. We found with the WPGraphQL for ACF v2.0 upgrade, these “Clone within a Group” values were all returning null. Elsewhere, when a Clone field is used outside of a Group, values are returned as expected.

I noticed issue #151 seems similar to this issue. I commented there and was advised to open a specific ticket. While that issue seems to focus on the image field, we are experiencing this issue regardless of field type within the clone.

Let me know if I can provide any further details! Happy to help.

Steps to reproduce

  1. Import attached ACF fields into a WordPress install.

    1. The zip includes 2 Field groups:

      “My Collection of Field Types” (text, radio button, image fields) with location of post type == post

      “My Group With Clone” (Clone field of “My Collection of Field Types” set in a Group field) with location of page template == default

  2. Create a new page using Default Template with the slug /group-clone.

  3. Under “My Group With Clone” section, fill in fields for text, radio button, and image.

  4. Query data for your page with this:

query NewQuery {
  page(id: "/group-clone", idType: URI) {
    template {
      ... on DefaultTemplate {
        myGroupWithClone {
          myGroupField {
            myTextField
            myRadioButtonField
            myImageField {
              node {
                altText
                sourceUrl
                mediaDetails {
                  height
                  width
                }
              }
            }
          }
        }
      }
    }
  }
}
  1. Notice all values within myGroupField return null instead of the data expected.

PHP or JSON export of the ACF Field Group(s)

acf-export-2024-03-01.json.zip

Additional context

Screen capture of ACF fields showing Clone field nested in Group field.

clone-in-group.mov

Additional troubleshooting info

When using a Clone field outside of a Group field context, all values from the cloned fields return as expected (as far as we have seen).

Enabling the "prefix_names" setting on clone fields does not resolve the issue.

Pulling the Clone field directly out from the Group field and setting it alongside the Group field (as a sibling) in the same Field Group set, allows the cloned field values to return as expected. We could potentially use this as a workaround, but it would require extensive refactoring within our CMS and frontend code bases. It would be great if the clone field could get working again as it was previously.

WPGraphQL Version

1.21.0

WPGraphQL For ACF Version

2.1.2

ACF (Advanced Custom Fields) Version. Free or Pro?

6.2.7 (Pro)

WordPress Version

6.4.3

PHP Version

8.2.10

Additional enviornment details

Initially, we experienced the issue while trialing the WPGraphQL for ACF upgrade on one of our existing production code bases. Since that environment is more complex and tailored to our team’s needs, I set up this test scenario in the most basic WordPress environment possible.

This test case environment included only the Twenty Twenty-Four theme and the 3 plugins listed above: Advanced Custom Fields PRO, WPGraphQL, and WPGraphQL for ACF.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL, WPGraphQL For ACF, ACF, etc.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: actionableReady for work to begintype: bugIssue that causes incorrect or unexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions