Support

Account

Home Forums Backend Issues (wp-admin) Notice: Undefined index: ID

Unread

Notice: Undefined index: ID

  • I’ve been contributing to the add-on ‘ACF Flexible Content Preview’.

    I’ve made some adjustments so that the pluging is able to access nested flexible content fields.

    It works as expected but gives an error in the WordPress Admin:

    Notice: Undefined index: ID in /wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php on line 361

    The code causing the issue is:

    foreach ( $fields as $field ) {
        if ( 'flexible_content' === $field['type'] ) {
    // Flexible is recursive structure with sub_fields into layouts
            foreach ( $field['layouts'] as $layout_field ) {
    
                if ( ! empty( $keys [ $layout_field['key'] ] ) ) {
                    continue;
                }
                $keys[ $layout_field['key'] ] = $layout_field['name'];
    PROBLEM >>> $sub_fields = (array) acf_get_fields($layout_field);
    
                foreach($sub_fields as $sub_field){
                    if('flexible_content' === $sub_field['type']){
                        foreach($sub_field['layouts'] as $layout_sub_field){
                            if ( ! empty( $keys [ $layout_sub_field['key'] ] ) ) {
                                continue;
                            }
                            $keys[ $layout_sub_field['key'] ] = $layout_sub_field['name'];
                        }
                    }
                }
    
            }
    
        }
    }

    As mentioned – it works like a boss but we’ve got this error… help appreciated

Viewing 1 post (of 1 total)

The topic ‘Notice: Undefined index: ID’ is closed to new replies.