StoutLogic / acf-builder

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

Repeater is not Working #180

Closed KhawarMehfooz closed 12 months ago

KhawarMehfooz commented 12 months ago

I am creating a Repeater field using ACF Builder, but I am encountering issues with it. The Repeater field is not displaying.

Here is the code snippet:

$wp_directory = ABSPATH;
$acf_builder_path = $wp_directory . 'wp-content/plugins/acf-builder/';
require_once $acf_builder_path . 'autoload.php';

use StoutLogic\AcfBuilder\FieldsBuilder;

$program = new FieldsBuilder('program');
$program
    ->addImage('program_header_image')
    ->addTextarea('presentation')
    ->addText('courses')
    ->addText('credits')
    ->addText('start')
    ->addText('hours')
    ->addText('recommended_baccalaureate_electives')
    ->addText('languages')
    ->addText('title_of_the_text_why_study')
    ->addText('reason_for_why_study')
    ->addText('title_of_facilities')
    ->addRepeater('image_slider', [
        'label' => 'Image Slider',
        'min' => 1,
        'button_label' => 'Add Slide',
    ])
        ->addImage('slide_image', ['label' => 'Slide Image']);

$program
    ->setLocation('post_type', '==', 'program');

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

Output:

https://github.com/StoutLogic/acf-builder/assets/80300513/9f936cf3-6a72-419d-a3f8-654a3f8be2c7

stevep commented 12 months ago

Quick question: is this the only ACF field group being used or are there others not shown? I'm wondering if there is some sort of collision of field keys causing this. Like another image_slider field being used somewhere else.

KhawarMehfooz commented 12 months ago

Yes, this is the only field group used in the project.

stevep commented 12 months ago

Hm, something else must be going on, but I'm not sure what. I used your code exactly in my functions.php file and installed ACF Builder in the same place you have it, and attached the field group to just the post post type and the repeater functions as normal.

If you open the dev console in the browser, are there any javascript errors?

WordPress Version: 6.3.2 ACF Version: 6.2.2 ACF Builder Version: 1.12.0

Screenshot 2023-11-02 at 9 29 57 AM
KhawarMehfooz commented 12 months ago

There is no proper error on the browser console.

https://github.com/StoutLogic/acf-builder/assets/80300513/e7f49708-2cf2-4220-8b8b-14595dc927a5

stevep commented 12 months ago

Are you using ACF or ACF Pro because only Pro supports repeater fields. If so which version?

KhawarMehfooz commented 12 months ago

I am using the free version of ACF. Version 6.2.2

KhawarMehfooz commented 12 months ago

I was thinking that I could create custom fields without ACF Pro by using this library.

stevep commented 12 months ago

Unfortunately no, this library is just a way to configure fields and field groups programatically for field types that already exist rather than using the Admin UI.

KhawarMehfooz commented 12 months ago

Thank you.