AdvancedCustomFields / AdvancedCustomFields/acf

Nested cloned repeater only works for 1 level

Open
#908 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Questions (Repeater)
-- Question (Text)
---- Answers (Repeater)
------ Answer (Text)
-------- Questions (Clone Questions)

I have a Flexible layout with a Clone field to the Component: Questions field.

The Component: Questions field then clones itself within the Answer repeater.

When adding a question and answer, it shows the Questions repeater however if I then add a question and answer, the Questions repeater no longer shows:

image

To Reproduce
Steps to reproduce the behavior:

  1. Go to ACF > Tools, import attached json.
  2. Go to ACF > Field Groups.
  3. Create new field.
  4. Add Clone field, called Questions and select "All fields from Component: Questions"
  5. Click Save.
  6. Go to Posts > Add New.
  7. Click on Add Question.
  8. Click on Add Answer
  9. Click on Add Question.

Expected behavior
Questions repeater will be cloned along with the other fields.

Code

[
    {
        "key": "group_66422429e4b06",
        "title": "Component: Questions",
        "fields": [
            {
                "key": "field_6642242adcbbf",
                "label": "Questions",
                "name": "questions",
                "aria-label": "",
                "type": "repeater",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "layout": "block",
                "pagination": 0,
                "min": 0,
                "max": 0,
                "collapsed": "field_66422443dcbc0",
                "button_label": "Add Question",
                "rows_per_page": 20,
                "sub_fields": [
                    {
                        "key": "field_66422443dcbc0",
                        "label": "Question",
                        "name": "question",
                        "aria-label": "",
                        "type": "text",
                        "instructions": "",
                        "required": 1,
                        "conditional_logic": 0,
                        "wrapper": {
                            "width": "",
                            "class": "",
                            "id": ""
                        },
                        "default_value": "",
                        "maxlength": "",
                        "placeholder": "",
                        "prepend": "",
                        "append": "",
                        "parent_repeater": "field_6642242adcbbf"
                    },
                    {
                        "key": "field_6642244bdcbc1",
                        "label": "Answers",
                        "name": "answers",
                        "aria-label": "",
                        "type": "repeater",
                        "instructions": "",
                        "required": 1,
                        "conditional_logic": 0,
                        "wrapper": {
                            "width": "",
                            "class": "",
                            "id": ""
                        },
                        "layout": "block",
                        "pagination": 0,
                        "min": 0,
                        "max": 0,
                        "collapsed": "field_66422471dcbc3",
                        "button_label": "Add Answer",
                        "rows_per_page": 20,
                        "sub_fields": [
                            {
                                "key": "field_66422459dcbc2",
                                "label": "Icon",
                                "name": "icon",
                                "aria-label": "",
                                "type": "select",
                                "instructions": "",
                                "required": 1,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "25",
                                    "class": "",
                                    "id": ""
                                },
                                "choices": {
                                    "icon-privacy": "Privacy",
                                    "icon-glare": "Heat\/Glare Reduction",
                                    "icon-safety": "Safety\/Security",
                                    "icon-sun": "UV Protection",
                                    "icon-energy-efficiency": "Energy\/Efficiency",
                                    "icon-half": "Daytime",
                                    "icon-full": "24 hour",
                                    "icon-neutral": "Neutral",
                                    "icon-reflective": "Reflective",
                                    "icon-clear": "Clear"
                                },
                                "default_value": false,
                                "return_format": "value",
                                "multiple": 0,
                                "allow_null": 0,
                                "ui": 0,
                                "ajax": 0,
                                "placeholder": "",
                                "parent_repeater": "field_6642244bdcbc1"
                            },
                            {
                                "key": "field_66422471dcbc3",
                                "label": "Answer",
                                "name": "answer",
                                "aria-label": "",
                                "type": "text",
                                "instructions": "",
                                "required": 1,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "75",
                                    "class": "",
                                    "id": ""
                                },
                                "default_value": "",
                                "maxlength": "",
                                "placeholder": "",
                                "prepend": "",
                                "append": "",
                                "parent_repeater": "field_6642244bdcbc1"
                            },
                            {
                                "key": "field_664224ee76777",
                                "label": "Products",
                                "name": "products",
                                "aria-label": "",
                                "type": "post_object",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "post_type": "",
                                "post_status": "",
                                "taxonomy": "",
                                "return_format": "object",
                                "multiple": 1,
                                "allow_null": 0,
                                "bidirectional": 0,
                                "ui": 1,
                                "bidirectional_target": [],
                                "parent_repeater": "field_6642244bdcbc1"
                            },
                            {
                                "key": "field_6642250f76778",
                                "label": "Inner Questions",
                                "name": "inner_questions",
                                "aria-label": "",
                                "type": "clone",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "clone": [
                                    "group_66422429e4b06"
                                ],
                                "display": "seamless",
                                "layout": "block",
                                "prefix_label": 0,
                                "prefix_name": 0,
                                "parent_repeater": "field_6642244bdcbc1"
                            }
                        ],
                        "parent_repeater": "field_6642242adcbbf"
                    }
                ]
            }
        ],
        "location": [
            [
                {
                    "param": "post_type",
                    "operator": "==",
                    "value": "post"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": false,
        "description": "",
        "show_in_rest": 0
    }
]

Version Information:

  • WordPress Version [e.g 6.3.1]: 6.5.3
  • PHP Version [e.g 8.0.2]: 8.3.4
  • ACF Version [e.g ACF Free 6.2, ACF PRO 6.3]: ACF PRO 6.2.9
  • Browser [e.g. chrome 103, safari 17]: Chrome Version 124.0.6367.119 (Official Build) (x86_64)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Import the attached JSON from ACF > Tools, then reproduce the nested repeater behavior in Posts > Add New using the listed steps. Done means the Questions repeater remains visible and can be added at the second nested level when the Clone field selects all fields from Component: Questions.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.