Support

Account

Home Forums General Issues Duplicated fields in REST API when using clone field

Solving

Duplicated fields in REST API when using clone field

  • I realize that ACF doesn’t natively support the REST API, but I had this same problem with 2 different ACF REST plugins (times’ acf-to-wp-api and airesvsg’s acf-to-rest-api , and am not sure if it’s on the ACF side of things, or how the plugins are parsing ACF data.

    The basic problem is that all of my fields which are in clone groups are getting duplicated in the REST API, under an object named after the clone group. I’ll also put the code below.

    In the image above, I have a set of fields in a clone field called “fundraising_clone_group”. In the REST JSON, those fields are shown within an object named after the clone group (so acf.fundraising_clone_group.project_total_cost), but also flattened, at the acf root key: (e.g. acf.project_total_cost).

    Has anyone else had this problem? I’m wondering if it’s something that should be fixed on the ACF to REST plugin side, or within ACF itself.

    "acf": {
          "fundraising_menu": "No",
          "include_in_insight": "",
          "test_date": "15/09/2016",
          "test_text": "<p>Just some test text</p>\n",
          "project_total_cost": "10",
          "project_total_match": "20",
          "fundraising_total_goal": "30",
          "funding_private_by_year": false,
          "funding_public_by_year": false,
          "funding_impact_by_year": false,
          "funding_notes": "<p>Funding notes go here</p>\n",
          "budget_notes": "<p>Budget notes go here.</p>\n",
          "fundraising_clone_group": {
            "project_total_cost": "10",
            "project_total_match": "20",
            "fundraising_total_goal": "30",
            "funding_private_by_year": false,
            "funding_public_by_year": false,
            "funding_impact_by_year": false,
            "funding_notes": "<p>Funding notes go here</p>\n",
            "budget_notes": "<p>Budget notes go here.</p>\n"
          },
  • Hi @dmajka

    I believe this issue is more related to the REST API plugin. Could you please get in touch with the plugin author?

    Thanks 🙂

  • Contents of the cloned fields aren’t shown at all in REST-API for me. Any idea?

    REST-API is not a plugin anymore: https://wordpress.org/news/2016/12/vaughan/

  • To those who are facing this issue, the issue is probably with the settings of the duplicated fields. Make sure you have set “Show in REST API?” to “Yes”. By default, ACF does not seem to be copying this setting from the original field. (Realization after 3-4 hours of debugging.)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.