Home Forums ACF PRO Relationship field inside repeater brokes ajax calls


Relationship field inside repeater brokes ajax calls

  • I’m trying to add a relationship type field inside a repeater (for posts) but the behavior is the following:


    First time I load (in this case is a page template) in the admin, I can add as many posts as I want in the repeater. But when I’m editing the page, the fetch fails for the posts and the fields are not rendered properly (sometimes they show empty, sometimes the spinner is there for ever and there’s an xhr error).

    I can see this error in the console when the fetch takes for ever:

    acf-input.min.js?ver=5.5.9:2 Uncaught TypeError: Cannot read property 'xhr' of undefined
    at Object.fetch (acf-input.min.js?ver=5.5.9:2)
    at Object.initialize (acf-input.min.js?ver=5.5.9:2)
    at acf-input.min.js?ver=5.5.9:1
    at d (acf-input.min.js?ver=5.5.9:1)
    at Object.i (acf-input.min.js?ver=5.5.9:1)
    at Object.do_action (acf-input.min.js?ver=5.5.9:1)
    at Object._ready_field (acf-input.min.js?ver=5.5.9:1)
    at d (acf-input.min.js?ver=5.5.9:1)
    at Object.i (acf-input.min.js?ver=5.5.9:1)
    at Object.do_action (acf-input.min.js?ver=5.5.9:1)

    If there’s no error, I can’t see the fields rendered, but just a white space
    Also, there’s this log from the server:

    script_filename = /www//wp-admin/post.php
    [0x00007fde4b786758] __construct() /www/wp-includes/class-wp-term.php:206
    [0x00007fde4b786550] __construct() /www/wp-includes/taxonomy.php:738
    [0x00007fff54c5ce20] get_term() unknown:0
    [0x00007fde4b785a90] array_map() /www/wp-includes/class-wp-term-query.php:673
    [0x00007fde4b780cd0] get_terms() /www/wp-includes/class-wp-term-query.php:291
    [0x00007fde4b780ad8] query() /www/wp-includes/taxonomy.php:1119
    [0x00007fde4b7803b0] get_terms() /www/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php:1157
    [0x00007fde4b780158] acf_get_terms() /www/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php:1308
    [0x00007fde4b77fb50] acf_get_taxonomy_terms() /www/wp-content/plugins/advanced-custom-fields-pro/fields/relationship.php:545
    [0x00007fff54c5d9f0] render_field() unknown:0
    [0x00007fde4b77e3a0] call_user_func_array() /www/wp-includes/class-wp-hook.php:298
    [0x00007fde4b77dbf0] apply_filters() /www/wp-includes/class-wp-hook.php:323
    [0x00007fde4b77d9e8] do_action() /www/wp-includes/plugin.php:453
    [0x00007fde4b77d2f8] do_action() /www/wp-content/plugins/advanced-custom-fields-pro/api/api-field.php:385
    [0x00007fde4b77d090] acf_render_field() /www/wp-content/plugins/advanced-custom-fields-pro/api/api-field.php:536
    [0x00007fde4b77c340] acf_render_field_wrap() /www/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php:397
    [0x00007fff54c5e520] render_field() unknown:0
    [0x00007fde4b77ae50] call_user_func_array() /www/wp-includes/class-wp-hook.php:298
    [0x00007fde4b77a6a0] apply_filters() /www/wp-includes/class-wp-hook.php:323
    [0x00007fde4b77a498] do_action() /www/wp-includes/plugin.php:453

    ACF Version tested: 5.5.9, 5.5.11
    WP Version: 4.7
    PHP Version: 5.6

    Any Idea?

  • I’m not seeing any problems when I test a relationship field as a sub field of a repeater.

    The JS errors you posts could indicate a couple of things. On is that there is a conflict with another script, try deactivating other plugins. The script conflict could also be in your theme. Another thing that can cause this are plugins that “defer” loading of scripts or in some other way alter the way that scripts are loaded.

    If no results are being show then this can happen due to a PHP error during that AJAX request. Turn on debugging and error logging and then check for errors in the error log

  • Hey thanks for the response, a few things.

    1 – The field works when it’s only 1 relationship. The site has thousands of posts so I started to think it was something related to ACF doing bad requests that caused timeout somehow.

    2 – I’ve deactivated all the plugins and switched the theme to test, and I still can see the issue.

    3 – Did u check the PHP error from the logs I posted? Or do you think it is not related at all?


  • The first JS error is generally caused by what I said above.

    I haven’t got a clue what the second thing you posted is. Looks like a list of files and functions that have been run but I don’t see any errors in that.

    If you have thousands of posts then yes, the AJAX request could be timing out. There have been other reports of this. But again, it could depend on other things that are running. However, if one relationship field loads then they all should since each one will create a separate ajax request. Usually this happens when trying to search, not when loading the page.

  • So.. there’s nothing I can do?

    I’ve just changed it to Post instead of relationship, but it would be a good idea to have a look at this (maybe u guys could test it with a small-medium database, ours have only 15.000 posts and it’s not working)

    Thanks, I guess it’s ‘solved’ this way.

  • That’s why I posted the link to open a new support ticket. There’s not really anything I can do to help you with this. More than likely it has to do with the size of the site. 15K posts is a lot of posts. Disabling the “search” option in the relationship field would probably help, but I can’t say for sure.

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

The topic ‘Relationship field inside repeater brokes ajax calls’ is closed to new replies.