Current status: Solved. . Done
Deleting a single field removes the entire field group
  • On version 3.4.3

    I am finding that if I delete a *single* field from a field group, then same the group, the *entire group* ends up being deleted. It is not sent to trash or anywhere recoverable - it is deleted entirely from the database and must be re-created.

    Luckily, recreating it - so long as the field names are exactly the same - links back to the post metadata, but zapping it unexpectedly and with no warning was a bit of a shock.

    In case it makes a difference, I'm adding the field group to a custom post type.
  • Hi @judgej

    I can confirm that that is unexpected behavior and I can't replicate the problem on my end.

    Perhaps there are some other scripts (from plugins / themes) which are corrupting the data?
  • Okay, some further information

    Plugins I have installed are:

    Select Advanced Custom Fields
    CSV Importer
    Posts 2 Posts
    Post Type Switcher
    Simple Image
    WCK Post Type Creator
    WooCommerce (with a number of woo plugins)

    The "tracks" post type is defined in code, in my custom child theme of Woo "canvas". It is pretty straight-forward:

    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => false,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true, // CHECKME
    'rewrite' => false,
    'capability_type' => 'post',
    'has_archive' => false,
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title', 'custom-fields', /*'editor', 'author', 'thumbnail', 'excerpt', 'comments'*/)

    The "albums" post type is actually the stock Woocommerce "products" post type.

    I have virtually no other customisation - I am in the early stages of setting this site up.
  • Now, I just tried setting up another group to show you screen shots, but as soon as I clicked on the "update" button, I was taken directly to the "Add new Post" page and the field group was discarded before it was even saved. This is weird. I'll try again.
  • Hmm, seems to be the "Update" button when editing a group. As soon as I press it, it zaps the field group. It is as though it actually performs a "Move to Trash". Looking at the source of the page, I don't see any obvious unclosed tags on the "move to trash" link.

    Just tried it again, with a field group with one saved field. I click on "Update" to update the field group and am taken straight here:

    http://dev.example.com/wp-admin/post.php?post=5928&action=edit&message=1

    I am presented with a blog post with the title "Track Details" (the same as the field group). Makes me wonder: when updating the field group, is something converting it to a standard blog post?
  • I have disabled the "Post Type Switcher" (1.1) plugin, and this time it seems to have worked - I can update a field group without it apparently converting into a blog post.

    The Post Type Switcher is an additional drop-down on the post edit page (not appearing on the field group edit page) that allows a post to be changed to another post type. Selecting the new post type does the updates to the database then refreshes the page, which is roughly what I am seeing. Something in your field group update POST or GET is triggering the post type switcher and firing it off.

    I've removed the Post Type Switcher now, as I no longer need it. Don't know if it is worth you trying it out so a formal warning can be given. TBH, I'm surprise there are not more clashes like this, the way some plugins use name-spacing of their functions and URLs as though they were the only plugin around ;-) That's WP fun for you :-)
  • Post type switcher looks at $_POST['pts_post_type'] when a post is saved. It does insert some JS and some HTML into the "edit field group" page, which strangely enough *I cannot see* on the page (it is only visible on the source - I've used "[" to open the tags, otherwise they don't display in this post):

    [a href="#" id="edit-post-type-switcher" class="hide-if-no-js">Edit[/a>

    [input type="hidden" id="pts-nonce-select" name="pts-nonce-select" value="fb716e0505" />
    [div id="post-type-select">
    [select name="pts_post_type" id="pts_post_type">

    [option value="post">Post[/option>
    [option value="page">Page[/option>
    [option value="product">Product[/option>
    [option value="shop_order">Order[/option>
    [option value="shop_coupon">Coupon[/option>
    [option value="track">Track[/option>
    [option value="portfolio">Portfolio Item[/option>

    [/select>
    [a href="#" id="save-post-type-switcher" class="hide-if-no-js button">OK[/a>
    [a href="#" id="cancel-post-type-switcher" class="hide-if-no-js">Cancel[/a>
    [/div>

    That plugin, so long as the pts_post_type parameter is posted, will call "set_post_type()" on the server, which I guess is defaulting to "post" and doing nasty things to your field group post type.

    I'll raise this with "Switch Post Type" too and point them here.
  • For reference, it has already been raised on the other plugin. I've linked that post here:

    http://wordpress.org/support/topic/plugin-post-type-switcher-conflict-with-acf-plugin?replies=2#post-3193232

    The workaround is to disable the "Post Type Switcher" (PTS) if you edit anything in the ACF field groups page, then re-enable it. Ideally, don't install both plugins at once as it is a bit risky. I suspect the bug is in PTS that probably needs to disable itself in the admin GUI for post types that have a hidden UI, i.e. post types that an admin cannot select to switch *to*.

    Please feel free to close if you think this is right. However, why the PTS widget markup is in the source of the page, and yet *not* displayed in your page, is a bit of a mystery to me.