Support

Account

Forum Replies Created

  • When updated to:

    <script>
      acf.add_filter('select2_args', function(args) {
        args.templateSelection = function(selection) {
          var $selection = jQuery('<span class="acf-selection"></span>');
    
          $selection.html(acf.escHtml(selection.text));
          $selection.data('element', selection.element);
    
          return $selection;
        }
    
        args.templateResult = function(selection) {
          var $selection = jQuery('<span class="acf-selection"></span>');
    
          $selection.html(acf.escHtml(selection.text));
          $selection.data('element', selection.element);
    
          return $selection;
        }
    
        return args;
      });
    </script>

    I renders both the selected value HTML and the HTML in the search result template (if you have HTML there also – like I have to allow icon selection)

  • …and this doesn’t happen every time unfortunately, so I cannot recreate it on demand but it is reported regularly by the editors and seems to have the same root – rearranging flexible sections.

  • I confirm – it is still a thing.

    It happens for different field setups – I’m still doing a more through investigation of the issue.

    The problem that was reported to me recently was an editor using a simple flexible section (text field, textarea, button + repeater containing only one select input per row) – one day the data is there and the next day the whole section has a structure (so I see lets say 6 repeater rows) but all is empty, even fields marked as required.

    Using a DB backup I noticed that the sections order was changed between the days – so it could support this idea suggested initially by wplus.

    And no John Huebner – there is no conditional logic for this section.

    So far (in my investigation) I can see that the data for this section seems to be still in the DB but ACF does not see it to fill the forms with the values.

    I have:
    ACF Pro Version 6.2.3
    WordPress 6.4.1
    PHP Version 8.1.23
    max_input_vars 10000 (which is not exceeded by the edited page)
    + reasonable log max_execution_time & max_input_time

  • You can make it kind of work.

    As you said the problem is that WP saves the order of boxes per post type so when
    used on ‘page’ type post you will have problems when you have different set of fields for the homepage and a generic page.

    On a homepage type of page (post) we can set order like:
    header, homepage fields
    but then when we go to a generic page where we have:
    header, generic fields

    So when the order is set for the homepage by the user like: header, homepage fields, WP saves this to the metafield meta-box-order_page and when you go to edit a generic page, WP tries to sort the meta boxes in order: header, homepage fields.

    Unfortunately there’s no ‘homepage fields’ group here so it only takes ‘header’ to ‘sorted’ set and the ‘homepage fields’ is left in the group where it was at first and that is ‘high’ priority group, then WP writes the metaboxes starting with ‘high’ then ‘sorted’ groups – this way on generic page we get ‘generic fields’, ‘headers’ and on a homepage ‘hompeage fields’ , ‘headers’.

    So the only way I see here is to disable all the sorting for ACF groups, thus leaving them in the initial ‘high’ priority group and relay on the order of the ACF groups in the define ACF groups admin panel section.

    As for disabling this I used the mentioned filter:

    add_filter('get_user_option_meta-box-order_page', 'removeAcfGroupsFromUserSort', 10, 3);
    
    function removeAcfGroupsFromUserSort($result, $option, $user)
        {
          if (empty($result) || empty($result['normal'])) return $result;
    
          $metaboxIds = explode(',', $result['normal']);
    
          $metaboxIdsOut = array_filter($metaboxIds, function($metaboxId) {
            return (!strstr($metaboxId, 'acf-group'));
          });
    
          $result['normal'] = implode(',', $metaboxIdsOut);
    
          return $result;
        }
  • Hmm.. the same problem here and only for one specific site. @buddyq Did you solve the problem?

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