Support

Account

Home Forums Backend Issues (wp-admin) Saved Field Data is missing after grouping Reply To: Saved Field Data is missing after grouping

  • They were designed for backend organization, but ACF needs to understand that organization. For this reason the fields in the group need to be children of the the “group” field. There is no other way given how ACF creates field to associate them.

    I can understand why this might cause confusion and could be frustrating, even though I personally would not consider this a bug, but then I’m not the developer. You can always submit a support ticket and see if you can get any more input from the developer https://support.advancedcustomfields.com/new-ticket/

    If I was going to move fields around in a way that would make something break I would probably add code to make them backwards compatible. For example this will load the old value into the editor:

    
    // on admin edit screen get old value to insert into new value
    add_filter('acf/load_value/key=new_field_key', 'load_load_field_name_value', 10, 3);
    function load_load_field_name_value($value, $post_id, $field) {
      if ($value === NULL) {
        // post never saved using new field
        $value = get_field('old_field_name', $post_id, false);
      }
      return $value;
    }
    

    and then something like this in the templates where the value is used

    
    $value = get_field('old_field_name');
    if ($value === NULL) {
      // do value saved to new field
      $value = get_field('old_field_name');
    }
    // do something with value
    

    Yes, this is a little more work, but nothing that I would not expect since I’m renaming a field. Maybe this is because I deal with this type of thing often when I make changes to custom themes created by either myself or some other dev.