-
Notifications
You must be signed in to change notification settings - Fork 63
Repeater
Steve Pfisterer edited this page May 13, 2016
·
4 revisions
One of ACF's more powerful features is a repeater field. A repeater allows an admin to create 1 to N number of entities comprised of a sub-group of fields. Read more about repeaters on ACF's website.
use StoutLogic\AcfBuilder\FieldsBuilder;
$slider = new FieldsBuilder('slider');
$slider
->addText('title')
->addRepeater('slides')
->addText('title')
->addWysiwyg('content');Here is an example of a simple slider. The slider itself has a title, and then there can be 1 to N number of slides that contain a title and content.
$slider->build() returns the following:
...
'fields' => [
[
...,
'name' => 'title',
'type' => 'text',
],
[
...,
'name' => 'slides',
'type' => 'repeater',
'sub_fields' => [
[
...,
'name' => 'title',
'type' => 'text',
],
[
...,
'name' => 'content',
'type' => 'wysiwyg',
],
],
],
],
...Want to contribute to this Wiki? Fork it and send a pull request.
© Stout Logic, LLC