• Stars
    star
    262
  • Rank 156,136 (Top 4 %)
  • Language
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cheatsheet for use with ACF Builder.

ACF Builder Cheatsheet

This cheatsheet consists of ACF Field Type arguments for use with ACF Builder as well as the known (most of which are not documented) configuration methods to assist in building fields. While the below field types reveal all of the possible configuration passable in the field type config array, most have available chainable methods to assist in building out cleaner, more readable code.

If you are new to ACF Builder and would like to learn more, you can read my guide here.

Table of Contents

Basic Content Choice Relational jQuery Layout Configuration
Text Wysiwyg Select Link Google Map Message Composing
Textarea Oembed Checkbox Post Object Date Picker Accordion Modifying
Number Image Radio Page Link Date Time Picker Tab Removing
Range File True / False Relationship Time Picker Group Choices
Email Gallery Taxonomy Color Picker Repeater Conditions
URL User Flexible Content Wrapper
Password Location
Custom / 3rd Party Position

Field Types

You can find a full reference of available settings on the official ACF documentation.

Basic

Text

$builder
    ->addText('text_field', [
        'label' => 'Text Field',
        'instructions' => '',
        'required' => 0,
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'default_value' => '',
        'placeholder' => '',
        'prepend' => '',
        'append' => '',
        'maxlength' => '',
  ]);

Official Documentation

Textarea

$builder
  ->addTextarea('textarea_field', [
      'label' => 'Textarea Field',
      'instructions' => '',
      'required' => 0,
      'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
      ],
      'default_value' => '',
      'placeholder' => '',
      'maxlength' => '',
      'rows' => '',
      'new_lines' => '', // Possible values are 'wpautop', 'br', or ''.
  ]);

Official Documentation

Number

$builder
    ->addNumber('number_Field', [
        'label' => 'Number Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'default_value' => '',
        'placeholder' => '',
        'prepend' => '',
        'append' => '',
        'min' => '',
        'max' => '',
        'step' => '',
  ]);

Range

$builder
    ->addRange('range_field', [
        'label' => 'Range Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'default_value' => '',
        'min' => '',
        'max' => '',
        'step' => '',
        'prepend' => '',
        'append' => '',
    ]);

Email

$builder
    ->addEmail('email_field', [
        'label' => 'Email Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'default_value' => '',
        'placeholder' => '',
        'prepend' => '',
        'append' => '',
    ]);

URL

$builder
    ->addUrl('url_field', [
        'label' => 'URL Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'default_value' => '',
        'placeholder' => '',
    ]);

Password

$builder
    ->addPassword('password_field', [
        'label' => 'Password Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'placeholder' => '',
        'prepend' => '',
        'append' => '',
    ]);

Content

Wysiwyg

$builder
    ->addWysiwyg('wysiwyg_field', [
        'label' => 'WYSIWYG Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'default_value' => '',
        'tabs' => 'all',
        'toolbar' => 'full',
        'media_upload' => 1,
        'delay' => 0,
    ]);

Official Documentation

Oembed

$builder
    ->addOembed('oembed_field', [
        'label' => 'Oembed Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'width' => '',
        'height' => '',
    ]);

Official Documentation

Image

$builder
    ->addImage('image_field', [
        'label' => 'Image Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'return_format' => 'array',
        'preview_size' => 'thumbnail',
        'library' => 'all',
        'min_width' => '',
        'min_height' => '',
        'min_size' => '',
        'max_width' => '',
        'max_height' => '',
        'max_size' => '',
        'mime_types' => '',
    ]);

Official Documentation

File

$builder
    ->addFile('file_Field', [
        'label' => 'File Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'return_format' => 'array',
        'library' => 'all',
        'min_size' => '',
        'max_size' => '',
        'mime_types' => '',
    ]);

Official Documentation

Gallery

$builder
    ->addGallery('gallery_field', [
        'label' => 'Gallery Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'return_format' => 'array',
        'min' => '',
        'max' => '',
        'insert' => 'append',
        'library' => 'all',
        'min_width' => '',
        'min_height' => '',
        'min_size' => '',
        'max_width' => '',
        'max_height' => '',
        'max_size' => '',
        'mime_types' => '',
    ]);

Official Documentation

Choice

Select

$builder
    ->addSelect('select_field', [
        'label' => 'Select Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'choices' => [],
        'default_value' => [],
        'allow_null' => 0,
        'multiple' => 0,
        'ui' => 0,
        'ajax' => 0,
        'return_format' => 'value',
        'placeholder' => '',
    ]);

Official Documentation

Checkbox

$builder
    ->addCheckbox('checkbox_field', [
        'label' => 'Checkbox Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'choices' => [],
        'allow_custom' => 0,
        'save_custom' => 0,
        'default_value' => [],
        'layout' => 'vertical',
        'toggle' => 0,
        'return_format' => 'value',
    ]);

Official Documentation

Radio

$builder
    ->addRadio('radio_field', [
        'label' => 'Radio Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'choices' => [],
        'allow_null' => 0,
        'other_choice' => 0,
        'save_other_choice' => 0,
        'default_value' => '',
        'layout' => 'vertical',
        'return_format' => 'value',
    ]);

Official Documentation

Button Group

$builder
    ->addButtonGroup('button_group_field', [
        'label' => 'Button Group Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'choices' => [],
        'allow_null' => 0,
        'default_value' => '',
        'layout' => 'horizontal',
        'return_format' => 'value',
    ]);

Official Documentation

True / False

$builder
    ->addTrueFalse('truefalse_field', [
        'label' => 'True / False Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'message' => '',
        'default_value' => 0,
        'ui' => 0,
        'ui_on_text' => '',
        'ui_off_text' => '',
    ]);

Official Documentation

Relational

Link

$builder
    ->addLink('link_field', [
        'label' => 'Link Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'return_format' => 'array',
    ]);

Official Documentation

Post Object

$builder
    ->addPostObject('post_object_field', [
        'label' => 'Post Object Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'post_type' => [],
        'taxonomy' => [],
        'allow_null' => 0,
        'multiple' => 0,
        'return_format' => 'object',
        'ui' => 1,
    ]);

Official Documentation

Page Link

$builder
    ->addPageLink('page_link_field', [
        'label' => 'Page Link Field',
        'type' => 'page_link',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'post_type' => [],
        'taxonomy' => [],
        'allow_null' => 0,
        'allow_archives' => 1,
        'multiple' => 0,
    ]);

Official Documentation

Relationship

$builder
    ->addRelationship('relationship_field', [
        'label' => 'Relationship Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'post_type' => [],
        'taxonomy' => [],
        'filters' => [
            0 => 'search',
            1 => 'post_type',
            2 => 'taxonomy',
        ],
        'elements' => '',
        'min' => '',
        'max' => '',
        'return_format' => 'object',
    ]);

Official Documentation

Taxonomy

$builder
    ->addTaxonomy('taxonomy_field', [
        'label' => 'Taxonomy Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'taxonomy' => 'category',
        'field_type' => 'checkbox',
        'allow_null' => 0,
        'add_term' => 1,
        'save_terms' => 0,
        'load_terms' => 0,
        'return_format' => 'id',
        'multiple' => 0,
    ]);

Official Documentation

User

$builder
    ->addUser('user_field', [
        'label' => 'User Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'role' => '',
        'allow_null' => 0,
        'multiple' => 0,
    ]);

Official Documentation

jQuery

Google Map

$builder
    ->addGoogleMap('google_map_field', [
        'label' => 'Google Map Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'center_lat' => '',
        'center_lng' => '',
        'zoom' => '',
        'height' => '',
    ]);

Official Documentation

Date Picker

$builder
    ->addDatePicker('date_picker_field', [
        'label' => 'Date Picker Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'display_format' => 'd/m/Y',
        'return_format' => 'd/m/Y',
        'first_day' => 1,
    ]);

Official Documentation

Date Time Picker

$builder
    ->addDateTimePicker('date_time_picker_field', [
        'label' => 'Date Time Picker Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
    ]);

Official Documentation

Time Picker

$builder
    ->addTimePicker('time_picker_field', [
        'label' => 'Time Picker Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'display_format' => 'g:i a',
        'return_format' => 'g:i a',
        'default_value' => '',
    ]);

Official Documentation

Color Picker

$builder
    ->addColorPicker('color_picker_field', [
        'label' => 'Color Picker Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'default_value' => '',
    ]);

Official Documentation

Layout

Message

$builder
    ->addMessage('message_field', 'message', [
        'label' => 'Message Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
            'width' => '',
            'class' => '',
            'id' => '',
        ],
        'message' => '',
        'new_lines' => 'wpautop', // 'wpautop', 'br', '' no formatting
        'esc_html' => 0,
    ]);

Accordion

$builder
    ->addAccordion('accordion_field', [
        'label' => 'Accordion Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'open' => 0,
        'multi_expand' => 0,
        'endpoint' => 0,
    ]);

$builder
    ->addAccordion('accordion_field_end')->endpoint();

Official Documentation

Tab

$builder
    ->addTab('tab_field', [
        'label' => 'Tab Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'default_value' => '',
        'placeholder' => '',
        'prepend' => '',
        'append' => '',
        'maxlength' => '',
        'placement' => '',
    ]);

Official Documentation

Group

$builder
    ->addGroup('group_field', [
        'label' => 'Group Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'layout' => 'block',
        'sub_fields' => [],
    ]);

Official Documentation

Repeater

$builder
    ->addRepeater('repeater_field', [
        'label' => 'Repeater Field',
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'collapsed' => '',
        'min' => 0,
        'max' => 0,
        'layout' => 'table',
        'button_label' => '',
        'sub_fields' => [],
    ]);

Official Documentation

Flexible Content

$builder
    ->addFlexibleContent('flexible_content_field', [
        'instructions' => '',
        'required' => 0,
        'conditional_logic' => [],
        'wrapper' => [
          'width' => '',
          'class' => '',
          'id' => '',
        ],
        'button_label' => 'Add Row',
        'min' => '',
        'max' => '',
    ]);

$builder
    ->addLayout('layout', [
        'label' => 'Layout',
        'display' => 'block',
        'sub_fields' => [],
        'min' => '',
        'max' => '',
    ]);

$builder
    ->addLayout(new FieldsBuilder());

Official Documentation

Configuration

Composing Fields

$builder
    ->addFields(new FieldsBuilder());

$builder
    ->addField('text', 'title')
        ->setKey('field_title')
        ->setLabel('My Label')
        ->setDefaultValue('Lorem ipsum')
        ->setInstructions('This is a title.')
        ->setRequired()
            ->setUnrequired()
        ->setConfig('placeholder', 'Enter the title');

Composing Custom/3rd Party Addon Fields

Add any other registered custom/3rd party ACF Fields using the addField($name, $type, $args) method.

$builder
    ->addFields(new FieldsBuilder());

$builder
    ->addField('icon', 'font-awesome')
        ->setLabel('My Icon')
        ->setInstructions('Select an icon')
        ->setConfig('save_format', 'class')

Modifying Fields

$builder
    ->modifyField('title', ['label' => 'Modified Title']);

$builder
    ->addFields(new FieldsBuilder())
        ->getField('title')
            ->modifyField('title', ['label' => 'Modified Title']);

Removing Fields

$builder
    ->removeField('title');

Field Choices

$builder
    ->addChoice('red')
    ->addChoice('blue')
    ->addChoice('green');

$builder
    ->addChoices(['red' => 'Red'], ['blue' => 'Blue'], ['green' => 'Green']);

Field Conditions

$builder
    ->conditional('true_false', '==', '0')
        ->and('true_false', '!=', '1')
        ->or('false_true', '==', '1');

Field Wrapper

$builder
    ->setWidth('30');

$builder
    ->setSelector('.field')
    ->setSelector('#field');

$builder
    ->setAttr('width', '30')
    ->setAttr('class', 'field')
    ->setAttr('id', 'field');

$builder
    ->setWrapper(['width' => '30', 'class' => 'field', 'id' => 'field']);

Field Group Location

$builder
    ->setLocation('post_type', '==', 'page')
        ->and('page_type', '==', 'front_page');

Field Group Locations

  • Post: post_type, post_type_list, post_type_archive, post_template, post_status, post_format, post_category, post_taxonomy, post
  • Page: page_template, page_type, page_parent, page
  • User: current_user, current_user_role, user_form, user_role
  • Forms: taxonomy, taxonomy_list, attachment, comment, widget, nav_menu, nav_menu_item, block, options_page
  • Custom: Official Documentation

Field Group Position

$builder = new FieldsBuilder('banner', ['position' => 'side']); // acf_after_title, normal, side

More Repositories

1

acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
PHP
310
star
2

navi

A developer-friendly alternative to the WordPress NavWalker.
PHP
253
star
3

sage-directives

A set of Blade directives for use with Roots Sage.
PHP
235
star
4

poet

Configuration-based post type, taxonomy, block category, and block registration for Sage 10.
PHP
148
star
5

sage-svg

A simple package for using inline SVGs with Sage 10.
PHP
91
star
6

acf-phone-number

A real ACF phone number field powered by libphonenumber and intl-tel-input
PHP
91
star
7

acf-editor-palette

A Gutenberg-like editor palette color picker field for Advanced Custom Fields.
PHP
80
star
8

blade-svg-sage

A simple package to add support for Blade SVG by Adam Wathan to Roots Sage.
PHP
71
star
9

modern-login

A whitelabeled and modernized wp-login.php
CSS
69
star
10

acf-field-boilerplate

Modernized PSR-2 boilerplate for creating custom fields for ACF5.
PHP
58
star
11

socialproof

A fluent interface for retrieving follower counts from social API's.
PHP
39
star
12

tailwindcss-pseudo

Tailwind CSS plugin to generate pseudo selector variants.
JavaScript
38
star
13

sage-html-forms

Create forms using HTMLForms.io and Sage 10 Blade components
PHP
37
star
14

pagi

A better WordPress pagination.
PHP
36
star
15

wp-smtp

Simple package for handling WordPress SMTP with .env when using the Roots stack.
PHP
33
star
16

acf-move-wp-editor

This is a simple ACF Field that moves the WordPress content editor of a post or page to the location of this field.
PHP
32
star
17

modern-acf-options

A modern approach to ACF Theme Options
CSS
30
star
18

crumb

A simple breadcrumb package for Sage 10.
PHP
29
star
19

bulma.styl

A Stylus translation of a modern CSS framework based on Flexbox
CSS
26
star
20

sage-password-protected

A simple password protection package for use with Roots Sage.
PHP
18
star
21

tailwindcss-container-sizes

Simple Tailwind plugin to generate container sizes
JavaScript
18
star
22

acf-fluent-helpers

Simple set of helper functions for ACF Fluent auto-loaded with Composer using generic function names.
PHP
14
star
23

wordpress-ui

Here lives a modernized approach to the WordPress Admin UI
CSS
14
star
24

sage-eject-blocks

Eject Sage 10 editor scripts to a optional lazy-loaded plugin.
PHP
13
star
25

plugin-meta

A simple meta package to install a few plugins I use regularly along with a couple related filters.
PHP
13
star
26

acf-blocks

PHP
12
star
27

docker-rtorrent-flood

Dockerfile
11
star
28

tailwindcss-border-styles

Tailwind CSS plugin to generate individual border side style classes.
JavaScript
8
star
29

acf-sidebar-selector

PHP
7
star
30

acf-encrypted-password

A better ACF Password Field that is encrypted using bcrypt.
PHP
7
star
31

gutentweaks

JavaScript
6
star
32

pomf

A simple implementation of the Pomf API.
PHP
4
star
33

acf-move-yoast

This is a simple ACF Field that moves the Yoast SEO metabox to the location of this field.
PHP
4
star
34

envoyer-deploy-commands

Simple deployment with Envoyer using Artisan
PHP
3
star
35

dotfiles

My personally used dotfiles on macOS
PHP
3
star
36

docker-mopidy-iris

Dockerfile
2
star
37

laravel-mix-jigsaw

Jigsaw's build tasks written as a Laravel Mix plugin.
JavaScript
2
star
38

nofollow-pretty-links

PHP
2
star
39

redirection-variables

PHP
2
star
40

wp-offload-media-avatars

A simple WP Media Offload integration for local avatar plugins.
PHP
2
star
41

rom-cli

A simple CLI tool to fetch prices from ROM Exchange
PHP
1
star
42

android

My personally used Android setup
1
star
43

allow-unsafe-links

Prevents WordPress from automatically adding noopener and noreferrer to outbound links.
PHP
1
star
44

acf-move-related-posts

This is a simple ACF Field that moves the Related Posts for WordPress metabox to the location of this field.
PHP
1
star
45

log1x.com

The current iteration of my personal website.
Vue
1
star
46

blade-filetype-icons

A package to easily make use of dmhendricks/file-icon-vectors in your Laravel Blade views.
PHP
1
star