Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested cloned repeater only works for 1 level #908

Open
gRoberts84 opened this issue May 13, 2024 · 1 comment
Open

Nested cloned repeater only works for 1 level #908

gRoberts84 opened this issue May 13, 2024 · 1 comment

Comments

@gRoberts84
Copy link

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)
@EffakT
Copy link

EffakT commented Sep 3, 2024

To replicate this issue, you don't need to go that far.

Repeater
---- Clone
-------- Clone

Will also replicate the issue.

Seems related to how clones are handled inside repeaters.
See get_cloned_fields function in the clone field is hitting the if ( isset( $this->cloning[ $field['key'] ] ) ) check for some reason, possibly due to the repeater?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants