Support

Account

Home Forums ACF PRO oddities with field key in repeater

Solved

oddities with field key in repeater

  • So I have this problem where I copied a working repeater group and then renamed all the slugs. Now I cannot save data for the copied group.

    The weird part is that the groups I copied which was STAFF shows the field keys next to each field but the new group shows something more like the fields slug.
    Could that be the reason?
    I tried deleting the newer group and redoing it from scratch but I still have the same results.

    Screen Captures
    Staff Screen Cap

    Screen cap of duplicated group

  • So my problem was a function I had setup. It was supposed to update the posts slug on save and it seems it was updating the field_key as a title slug as well.

    This is the code, if you have any suggestions how to make it only update posts and page slugs I’d love to hear it.

    // Updates slug from post title on Save
    function myplugin_update_slug( $data, $postarr ) {
        if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
            $data['post_name'] = sanitize_title( $data['post_title'] );
        }
        return $data;
    }
    add_filter( 'wp_insert_post_data', 'myplugin_update_slug', 99, 2 );
  • Hey, don’t know if you found you an answer to this or not. When you posted a reply to your own question it was removed from the “Awaiting Reply” list which is where most people look for questions needing help.

    Anyway. the problem is the field keys, this must begin with field_. You need to find the cause of these field keys being replaced. Also, you cannot duplicate field keys from one field group to another, so if you do copy a repeater then you need to alter the keys to be unique.

  • Thanks, no fix yet, i moved it to the back burner. But I thank you for the follow-up and your past assistance with my woes. Which were all caused by that function cited above our responses.

  • Ahh, I think I see. If you’re still looking to do that you need to check the post_type value of the post being updated. The ACF fields are being changed because you’re changing all post slugs, which is altering the field keys of the custom fields. Fields in ACF are a custom post type that the field keys are the post titles.

  • Just to link to solution if someone needs it. Not so easy to troubleshoot.

    https://support.advancedcustomfields.com/forums/topic/fields-not-saving-slug/

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

The topic ‘oddities with field key in repeater’ is closed to new replies.