Fields - Repeaters

Table of contents

Example code

Below you will find some simple demo code to show you how to get started. For a more advanced OOP approach, how to use Bricks for layouts, how to display the data and more tips and tricks check out The Fewbricks Demo Theme.


namespace App\KAN\Fewbricks;

use Fewbricks\ACF\FieldGroup;
use Fewbricks\ACF\FieldGroupLocationRule;
use Fewbricks\ACF\FieldGroupLocationRuleGroup;
use Fewbricks\ACF\Fields\Repeater;
use Fewbricks\ACF\Fields\Select;
use Fewbricks\ACF\Fields\Text;

$field_group = new FieldGroup('Demo content', 'demo_content');

$repeater = (new Repeater('List items', 'list_items', '2002171553a'))
    ->set_button_label('Add item')
    ->add_field(new Text('Name', 'name', '2002171553o'))
    new Select('Importance', 'importance', '2002171554o'))
                'procrastinable' => 'Procrastinable',
                'important' => 'Important',
                'very_important' => 'Very important',


    (new FieldGroupLocationRuleGroup())
            new FieldGroupLocationRule('post_type', '==', 'page')