Support

Account

Home Forums Bug Reports All fields hidden when taxonomy is registered locally with save_terms enabled

Solving

All fields hidden when taxonomy is registered locally with save_terms enabled

  • Situation
    I register a local field group through acf_add_local_field_group and add a taxonomy field (through the fields parameter) with the following settings:

    
    array(
    	'key' => 'field_platforms',
    	'label' => 'Platforms',
    	'name' => 'platforms',
    	'type' => 'taxonomy',
    	'taxonomy' => 'mycustomtaxonomy',
    	'field_type' => 'checkbox',
    	'load_terms' => 1,
    	'save_terms' => 1,
    )
    

    Behavior
    When I click a checkbox to save the taxonomy to the currently edited post, an AJAX call is triggered with the following form data:

    
    post_taxonomy[]:
    post_taxonomy[]:14
    action:acf/post/get_field_groups
    exists[]:group_immo_edit
    

    The call returns an empty result:

    {"success":true,"data":[]}

    This causes the complete ACF UI to be hidden, leaving a blank edit screen.
    This AJAX call is only triggered when save_terms is set to true.

    Expected behavior
    Save selected terms to post through AJAX while accounting for field groups registered locally or don’t save terms through AJAX, but only through save_post action.

    Setup
    WP 4.5.2
    ACF PRO 5.3.8

  • What are the location rules on your field group?

    Is this happening in a particular browser? Have you tried testing in another browser?

    It sounds like the group is being hidden because selecting a term in the taxonomy field is triggering the group to not be active. I testes this and I’m not seeing the behavior you describe.

  • I further looked into it. And you are right, it’s actually not a bug. I had to make sure that the local field group is also registered when the wp_ajax_acf/post/get_field_groups action runs. A classic hooks problem.

    This can be closed. Thanks for your help!

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

The topic ‘All fields hidden when taxonomy is registered locally with save_terms enabled’ is closed to new replies.