Support

Account

Home Forums Front-end Issues Nested group always returns too few rows

Unread

Nested group always returns too few rows

  • I built quite a complicated field group that stacks groups, repeaters and flex content for a custom post type “Person”. Because the original JSON has over 3000 lines I deleted everything except the bit that continues to produce the error.

    When I retrieve the last nested group on the front-end, the data is simply incomplete for no apparent reason. I can scramble the fields, remove and recreate them, or even remove and recreate the entire field group, yet the last nested group always returns exactly the first two fields in line. If I swap fields around inside the group, so other fields are now the first two in line, then these are retrieved and the rest is missing.

    Please refer to the attached images of the database records and the editor screen. Down below you will also find:

    • The field group JSON
    • The PHP that retrieves the data
    • The var_dump() data

    This is not the first time this happened, I have no idea why, and it drives me mad. Any help is very much appreciated.

    This is the exported JSON:

    [
        {
            "key": "group_5e1fe6b9421b6",
            "title": "Person",
            "fields": [
                {
                    "key": "field_5e1febc32d4ea",
                    "label": "Front data",
                    "name": "",
                    "type": "tab",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "placement": "top",
                    "endpoint": 0,
                    "wpml_cf_preferences": 0
                },
                {
                    "key": "field_5e1febcd2d4eb",
                    "label": "Front data",
                    "name": "front",
                    "type": "group",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "layout": "block",
                    "wpml_cf_preferences": 0,
                    "sub_fields": [
                        {
                            "key": "field_5e1febdc2d4ec",
                            "label": "Names",
                            "name": "names",
                            "type": "flexible_content",
                            "instructions": "A person can have multiple names in several different styles.",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "wpml_cf_preferences": 0,
                            "layouts": {
                                "layout_5e1febeee8636": {
                                    "key": "layout_5e1febeee8636",
                                    "name": "western",
                                    "label": "Western ([first name] [middle names] [last name])",
                                    "display": "block",
                                    "sub_fields": [
                                        {
                                            "key": "field_5e1fec012d4ed",
                                            "label": "This name as spelled in the current language",
                                            "name": "local",
                                            "type": "group",
                                            "instructions": "",
                                            "required": 0,
                                            "conditional_logic": 0,
                                            "wrapper": {
                                                "width": "",
                                                "class": "",
                                                "id": ""
                                            },
                                            "layout": "block",
                                            "wpml_cf_preferences": 0,
                                            "sub_fields": [
                                                {
                                                    "key": "field_5e1fec0c2d4ee",
                                                    "label": "First name",
                                                    "name": "nameFirst",
                                                    "type": "group",
                                                    "instructions": "",
                                                    "required": 0,
                                                    "conditional_logic": 0,
                                                    "wrapper": {
                                                        "width": "",
                                                        "class": "",
                                                        "id": ""
                                                    },
                                                    "layout": "block",
                                                    "wpml_cf_preferences": 0,
                                                    "sub_fields": [
                                                        {
                                                            "key": "field_5e1fec232d4ef",
                                                            "label": "Reliability",
                                                            "name": "reliability",
                                                            "type": "select",
                                                            "instructions": "",
                                                            "required": 1,
                                                            "conditional_logic": 0,
                                                            "wrapper": {
                                                                "width": "",
                                                                "class": "",
                                                                "id": ""
                                                            },
                                                            "choices": {
                                                                "name": "Name is known",
                                                                "alleged": "Name is alleged",
                                                                "unknown": "Name is unknown",
                                                                "abbr": "Only abbreviated name is known"
                                                            },
                                                            "default_value": [
                                                                "name"
                                                            ],
                                                            "allow_null": 0,
                                                            "multiple": 0,
                                                            "ui": 0,
                                                            "return_format": "value",
                                                            "wpml_cf_preferences": 0,
                                                            "ajax": 0,
                                                            "placeholder": ""
                                                        },
                                                        {
                                                            "key": "field_5e1fec552d4f0",
                                                            "label": "Full",
                                                            "name": "full",
                                                            "type": "text",
                                                            "instructions": "",
                                                            "required": 0,
                                                            "conditional_logic": 0,
                                                            "wrapper": {
                                                                "width": "",
                                                                "class": "",
                                                                "id": ""
                                                            },
                                                            "wpml_cf_preferences": 0,
                                                            "default_value": "",
                                                            "placeholder": "",
                                                            "prepend": "",
                                                            "append": "",
                                                            "maxlength": ""
                                                        },
                                                        {
                                                            "key": "field_5e1fec622d4f1",
                                                            "label": "Abbreviated",
                                                            "name": "abbr",
                                                            "type": "text",
                                                            "instructions": "",
                                                            "required": 0,
                                                            "conditional_logic": 0,
                                                            "wrapper": {
                                                                "width": "",
                                                                "class": "",
                                                                "id": ""
                                                            },
                                                            "wpml_cf_preferences": 0,
                                                            "default_value": "",
                                                            "placeholder": "",
                                                            "prepend": "",
                                                            "append": "",
                                                            "maxlength": ""
                                                        },
                                                        {
                                                            "key": "field_5e1fecd8d6cf5",
                                                            "label": "Testfield",
                                                            "name": "testfield",
                                                            "type": "text",
                                                            "instructions": "",
                                                            "required": 1,
                                                            "conditional_logic": 0,
                                                            "wrapper": {
                                                                "width": "",
                                                                "class": "",
                                                                "id": ""
                                                            },
                                                            "wpml_cf_preferences": 0,
                                                            "default_value": "",
                                                            "placeholder": "",
                                                            "prepend": "",
                                                            "append": "",
                                                            "maxlength": ""
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ],
                                    "min": "",
                                    "max": ""
                                }
                            },
                            "button_label": "Add name",
                            "min": "",
                            "max": ""
                        }
                    ]
                }
            ],
            "location": [
                [
                    {
                        "param": "post_type",
                        "operator": "==",
                        "value": "person"
                    }
                ]
            ],
            "menu_order": 0,
            "position": "normal",
            "style": "default",
            "label_placement": "top",
            "instruction_placement": "label",
            "hide_on_screen": "",
            "active": true,
            "description": ""
        }
    ]

    This PHP snipped attempts to retrieve the data:

    echo '<pre>';
    var_dump(
    	$id , // The post ID
    	get_sub_field( 'local' , $id ) , // After have_rows()
    	get_field( 'front_names_0_local_nameFirst' , $id ) // The full field name
    );
    echo '</pre>';

    This is what it spits out:

    int(3354)
    array(1) {
    	["nameFirst"]=>
    	array(2) {
    		["reliability"]=>
    		string(4) "name"
    		["full"]=>
    		string(19) "The full first name"
    	}
    }
    array(2) {
    	["reliability"]=>
    	string(4) "name"
    	["full"]=>
    	string(19) "The full first name"
    }
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.