StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
794 stars 62 forks source link

ACF 6 repeater pagination not working #161

Closed Alex-Hay closed 1 month ago

Alex-Hay commented 2 years ago

Hi there,

I've been using ACF Composer to create fields and generate blocks on a Sage site I'm working on. ACF 6 adds a useful pagination feature, which I've tried to use using the code below. It adds pagination, but it's broken. Here's a video highlighting the issue:

https://share.cleanshot.com/LZDMSf

->addRepeater('news', [ 'label' => 'News', 'min' => 1, 'button_label' => 'Add Section', 'pagination' => 1, 'rows_per_page' => 2, ]) Thanks!

stevep commented 2 years ago

@Alex-Hay Sorry for the delay I was traveling last week.

I'm not able to recreate the issue with ACF 6.0.2

I created a paginated repeater with the ACF UI directly, as well with code via ACF Builder and they both work identically.

https://user-images.githubusercontent.com/9717/195189571-59e5f72e-a2f4-4b96-94ef-f4b8aa3927f2.mp4

Here is the code I was using:

$group = new FieldsBuilder('ACF_Builder_Test');
$group->addRepeater('news', [
    'label' => 'News', 
    'min' => 1, 'button_label' => 
    'Add Section', 
    'pagination' => 1, 
    'rows_per_page' => 2, 
    ])
    ->addText('title', ['label' => 'Title'])
  ->setLocation('post_type', '==', 'post');

acf_add_local_field_group($group->build());

If the latest version of ACF 6.0.2 doesn't work can you post more of the PHP code used for the field group? I can use that to try to recreate locally.

Alex-Hay commented 1 month ago

Coming back to this a thousand years later: I was running into issues because pagination is not supported on fields inside of ACF blocks. Apologies I should have mentioned that in my initial issue.

"Repeater pagination will not work for fields used inside an ACF Block, as there would be no performance benefit given the repeater data is already stored in the DOM."

It's a shame as there are definitely uses cases where this would be helpful but that's up to WP Engine I guess 🤷