Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
400 stars 53 forks source link

->addGroup doesn't work #164

Closed octoxan closed 1 year ago

octoxan commented 1 year ago

Following the documentation and the cheatsheet, the following code does not work. It creates an empty group in the ACF UI.

Perhaps I'm adding the sub_fields wrong, but there is no documentation for that anywhere it seems.

$footer->addGroup('column_1', [
    'label' => 'Column 1',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => [],
    'wrapper' => [
    'width' => '',
    'class' => '',
    'id' => '',
    ],
    'layout' => 'block',
    'sub_fields' => [
        'column_1_title' => [
            'label' => 'Title',
            'type' => 'text',
        ],
    ]
]);

Tried this as well, still an empty group:

$footer->addGroup('column_1', [
                'label' => 'Column 1',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => [],
                'wrapper' => [
                    'width' => '',
                    'class' => '',
                    'id' => '',
                ],
                'layout' => 'block',
                'sub_fields' => [
                    [
                        'name' => 'column_1_title',
                        'label' => 'Title',
                        'type' => 'text',
                    ],
                ],
            ]);
mike-sheppard commented 1 year ago

hey @octoxan try this:

$footer
    ->addGroup('column_1', ['layout' => 'block'])
        ->addText('title', ['label' => 'Title'])
    ->endGroup();

`+ more docs/info can be found over on: https://github.com/StoutLogic/acf-builder/

octoxan commented 1 year ago

Thanks @mike-sheppard that worked perfectly! There's no grouping docs at https://github.com/StoutLogic/acf-builder/ (unless I'm blind lol), and the docs at https://github.com/Log1x/acf-builder-cheatsheet#group for groups are incorrect apparently. I'll make a PR to the cheatsheet.