StoutLogic / acf-builder

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

Using repeater field with default wordpress and theme #157

Open EmWe5 opened 2 years ago

EmWe5 commented 2 years ago

I'm experiencing problems to make acf-builder work on a standard wordpress setup. I'm using:

My approach:

In the theme folder I created a composer.json file with acf-builder inside and ran composer install. In the functions.php I required the autoload file. (require_once('vendor/stoutlogic/acf-builder/autoload.php');) I know that acf-builder is relying on the 3rd party library that has also been installed successfully. To avoid 500 erros I specified "button_label" on my repeater field.

The problem

There is no error but in the backend there is no button showing up on the repeater field. I mean the button like "Add whatever". Same behaviour on Flexible Content element.

There are no errors in the browser console. The fields like the text field are working normally.

Here is my code of functions.php

require_once('vendor/stoutlogic/acf-builder/autoload.php');

$banner = new StoutLogic\AcfBuilder\FieldsBuilder('banner');
$banner
    ->addText('title')
    ->addRepeater('columns', [
        'button_label' => 'Add new element'
    ])
    ->addText('column_headline')
    ->endRepeater()
    ->addText('other_text');

$banner->setLocation('post_type', '==', 'page');

add_action('acf/init', function() use ($banner) {
    acf_add_local_field_group($banner->build());
});