├── .github └── FUNDING.yml └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Log1x 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ACF Builder Cheatsheet 2 | 3 | This cheatsheet consists of ACF Field Type arguments for use with [ACF Builder](https://github.com/StoutLogic/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. 4 | 5 | If you are new to ACF Builder and would like to learn more, you can read my guide [here](https://roots.io/guides/using-acf-builder-with-sage/). 6 | 7 | ## Table of Contents 8 | 9 | | [Basic](#basic) | [Content](#content) | [Choice](#choice) | [Relational](#relational) | [jQuery](#jquery) | [Layout](#layout) | [Configuration](#configuration) | 10 | |:----------------------|:--------------------|:-----------------------------|:------------------------------|:--------------------------------------|:--------------------------------------|:----------------------------------| 11 | | [Text](#text) | [Wysiwyg](#wysiwyg) | [Select](#select) | [Link](#link) | [Google Map](#google-map) | [Message](#message) | [Composing](#composing-fields) | 12 | | [Textarea](#textarea) | [Oembed](#oembed) | [Checkbox](#checkbox) | [Post Object](#post-object) | [Date Picker](#date-picker) | [Accordion](#accordion) | [Modifying](#modifying-fields) | 13 | | [Number](#number) | [Image](#image) | [Radio](#radio) | [Page Link](#page-link) | [Date Time Picker](#date-time-picker) | [Tab](#tab) | [Removing](#removing-fields) | 14 | | [Range](#range) | [File](#file) | [True / False](#true--false) | [Relationship](#relationship) | [Time Picker](#time-picker) | [Group](#group) | [Choices](#field-choices) | 15 | | [Email](#email) | [Gallery](#gallery) | | [Taxonomy](#taxonomy) | [Color Picker](#color-picker) | [Repeater](#repeater) | [Conditions](#field-conditions) | 16 | | [URL](#url) | | | [User](#user) | | [Flexible Content](#flexible-content) | [Wrapper](#field-wrapper) | 17 | | [Password](#password) | | | | | | [Location](#field-group-location) | 18 | | [Custom / 3rd Party](#composing-custom3rd-party-addon-fields) | | | | | | [Position](#field-group-position) | 19 | 20 | ## Field Types 21 | 22 | You can find a full reference of available settings on the [official ACF documentation](https://www.advancedcustomfields.com/resources/register-fields-via-php/#field-type%20settings). 23 | 24 | ### Basic 25 | 26 | #### Text 27 | ```php 28 | $builder 29 | ->addText('text_field', [ 30 | 'label' => 'Text Field', 31 | 'instructions' => '', 32 | 'required' => 0, 33 | 'wrapper' => [ 34 | 'width' => '', 35 | 'class' => '', 36 | 'id' => '', 37 | ], 38 | 'default_value' => '', 39 | 'placeholder' => '', 40 | 'prepend' => '', 41 | 'append' => '', 42 | 'maxlength' => '', 43 | ]); 44 | ``` 45 | [Official Documentation]( https://www.advancedcustomfields.com/resources/text) 46 | 47 | #### Textarea 48 | ```php 49 | $builder 50 | ->addTextarea('textarea_field', [ 51 | 'label' => 'Textarea Field', 52 | 'instructions' => '', 53 | 'required' => 0, 54 | 'wrapper' => [ 55 | 'width' => '', 56 | 'class' => '', 57 | 'id' => '', 58 | ], 59 | 'default_value' => '', 60 | 'placeholder' => '', 61 | 'maxlength' => '', 62 | 'rows' => '', 63 | 'new_lines' => '', // Possible values are 'wpautop', 'br', or ''. 64 | ]); 65 | ``` 66 | [Official Documentation](https://www.advancedcustomfields.com/resources/textarea) 67 | 68 | #### Number 69 | ```php 70 | $builder 71 | ->addNumber('number_Field', [ 72 | 'label' => 'Number Field', 73 | 'instructions' => '', 74 | 'required' => 0, 75 | 'conditional_logic' => [], 76 | 'wrapper' => [ 77 | 'width' => '', 78 | 'class' => '', 79 | 'id' => '', 80 | ], 81 | 'default_value' => '', 82 | 'placeholder' => '', 83 | 'prepend' => '', 84 | 'append' => '', 85 | 'min' => '', 86 | 'max' => '', 87 | 'step' => '', 88 | ]); 89 | ``` 90 | 91 | #### Range 92 | ```php 93 | $builder 94 | ->addRange('range_field', [ 95 | 'label' => 'Range Field', 96 | 'instructions' => '', 97 | 'required' => 0, 98 | 'conditional_logic' => [], 99 | 'wrapper' => [ 100 | 'width' => '', 101 | 'class' => '', 102 | 'id' => '', 103 | ], 104 | 'default_value' => '', 105 | 'min' => '', 106 | 'max' => '', 107 | 'step' => '', 108 | 'prepend' => '', 109 | 'append' => '', 110 | ]); 111 | ``` 112 | 113 | #### Email 114 | ```php 115 | $builder 116 | ->addEmail('email_field', [ 117 | 'label' => 'Email Field', 118 | 'instructions' => '', 119 | 'required' => 0, 120 | 'conditional_logic' => [], 121 | 'wrapper' => [ 122 | 'width' => '', 123 | 'class' => '', 124 | 'id' => '', 125 | ], 126 | 'default_value' => '', 127 | 'placeholder' => '', 128 | 'prepend' => '', 129 | 'append' => '', 130 | ]); 131 | ``` 132 | 133 | #### URL 134 | ```php 135 | $builder 136 | ->addUrl('url_field', [ 137 | 'label' => 'URL Field', 138 | 'instructions' => '', 139 | 'required' => 0, 140 | 'conditional_logic' => [], 141 | 'wrapper' => [ 142 | 'width' => '', 143 | 'class' => '', 144 | 'id' => '', 145 | ], 146 | 'default_value' => '', 147 | 'placeholder' => '', 148 | ]); 149 | ``` 150 | 151 | #### Password 152 | ```php 153 | $builder 154 | ->addPassword('password_field', [ 155 | 'label' => 'Password Field', 156 | 'instructions' => '', 157 | 'required' => 0, 158 | 'conditional_logic' => [], 159 | 'wrapper' => [ 160 | 'width' => '', 161 | 'class' => '', 162 | 'id' => '', 163 | ], 164 | 'placeholder' => '', 165 | 'prepend' => '', 166 | 'append' => '', 167 | ]); 168 | ``` 169 | 170 | ### Content 171 | 172 | #### Wysiwyg 173 | ```php 174 | $builder 175 | ->addWysiwyg('wysiwyg_field', [ 176 | 'label' => 'WYSIWYG Field', 177 | 'instructions' => '', 178 | 'required' => 0, 179 | 'conditional_logic' => [], 180 | 'wrapper' => [ 181 | 'width' => '', 182 | 'class' => '', 183 | 'id' => '', 184 | ], 185 | 'default_value' => '', 186 | 'tabs' => 'all', 187 | 'toolbar' => 'full', 188 | 'media_upload' => 1, 189 | 'delay' => 0, 190 | ]); 191 | ``` 192 | [Official Documentation](https://www.advancedcustomfields.com/resources/wysiwyg) 193 | 194 | #### Oembed 195 | ```php 196 | $builder 197 | ->addOembed('oembed_field', [ 198 | 'label' => 'Oembed Field', 199 | 'instructions' => '', 200 | 'required' => 0, 201 | 'conditional_logic' => [], 202 | 'wrapper' => [ 203 | 'width' => '', 204 | 'class' => '', 205 | 'id' => '', 206 | ], 207 | 'width' => '', 208 | 'height' => '', 209 | ]); 210 | ``` 211 | [Official Documentation](https://www.advancedcustomfields.com/resources/oembed) 212 | 213 | #### Image 214 | ```php 215 | $builder 216 | ->addImage('image_field', [ 217 | 'label' => 'Image Field', 218 | 'instructions' => '', 219 | 'required' => 0, 220 | 'conditional_logic' => [], 221 | 'wrapper' => [ 222 | 'width' => '', 223 | 'class' => '', 224 | 'id' => '', 225 | ], 226 | 'return_format' => 'array', 227 | 'preview_size' => 'thumbnail', 228 | 'library' => 'all', 229 | 'min_width' => '', 230 | 'min_height' => '', 231 | 'min_size' => '', 232 | 'max_width' => '', 233 | 'max_height' => '', 234 | 'max_size' => '', 235 | 'mime_types' => '', 236 | ]); 237 | ``` 238 | [Official Documentation](https://www.advancedcustomfields.com/resources/image) 239 | 240 | #### File 241 | ```php 242 | $builder 243 | ->addFile('file_Field', [ 244 | 'label' => 'File Field', 245 | 'instructions' => '', 246 | 'required' => 0, 247 | 'conditional_logic' => [], 248 | 'wrapper' => [ 249 | 'width' => '', 250 | 'class' => '', 251 | 'id' => '', 252 | ], 253 | 'return_format' => 'array', 254 | 'library' => 'all', 255 | 'min_size' => '', 256 | 'max_size' => '', 257 | 'mime_types' => '', 258 | ]); 259 | ``` 260 | [Official Documentation](https://www.advancedcustomfields.com/resources/file) 261 | 262 | #### Gallery 263 | ```php 264 | $builder 265 | ->addGallery('gallery_field', [ 266 | 'label' => 'Gallery Field', 267 | 'instructions' => '', 268 | 'required' => 0, 269 | 'conditional_logic' => [], 270 | 'wrapper' => [ 271 | 'width' => '', 272 | 'class' => '', 273 | 'id' => '', 274 | ], 275 | 'return_format' => 'array', 276 | 'min' => '', 277 | 'max' => '', 278 | 'insert' => 'append', 279 | 'library' => 'all', 280 | 'min_width' => '', 281 | 'min_height' => '', 282 | 'min_size' => '', 283 | 'max_width' => '', 284 | 'max_height' => '', 285 | 'max_size' => '', 286 | 'mime_types' => '', 287 | ]); 288 | ``` 289 | [Official Documentation](https://www.advancedcustomfields.com/resources/gallery) 290 | 291 | ### Choice 292 | 293 | #### Select 294 | ```php 295 | $builder 296 | ->addSelect('select_field', [ 297 | 'label' => 'Select Field', 298 | 'instructions' => '', 299 | 'required' => 0, 300 | 'conditional_logic' => [], 301 | 'wrapper' => [ 302 | 'width' => '', 303 | 'class' => '', 304 | 'id' => '', 305 | ], 306 | 'choices' => [], 307 | 'default_value' => [], 308 | 'allow_null' => 0, 309 | 'multiple' => 0, 310 | 'ui' => 0, 311 | 'ajax' => 0, 312 | 'return_format' => 'value', 313 | 'placeholder' => '', 314 | ]); 315 | ``` 316 | [Official Documentation](https://www.advancedcustomfields.com/resources/select) 317 | 318 | #### Checkbox 319 | ```php 320 | $builder 321 | ->addCheckbox('checkbox_field', [ 322 | 'label' => 'Checkbox Field', 323 | 'instructions' => '', 324 | 'required' => 0, 325 | 'conditional_logic' => [], 326 | 'wrapper' => [ 327 | 'width' => '', 328 | 'class' => '', 329 | 'id' => '', 330 | ], 331 | 'choices' => [], 332 | 'allow_custom' => 0, 333 | 'save_custom' => 0, 334 | 'default_value' => [], 335 | 'layout' => 'vertical', 336 | 'toggle' => 0, 337 | 'return_format' => 'value', 338 | ]); 339 | ``` 340 | [Official Documentation](https://www.advancedcustomfields.com/resources/checkbox) 341 | 342 | #### Radio 343 | ```php 344 | $builder 345 | ->addRadio('radio_field', [ 346 | 'label' => 'Radio Field', 347 | 'instructions' => '', 348 | 'required' => 0, 349 | 'conditional_logic' => [], 350 | 'wrapper' => [ 351 | 'width' => '', 352 | 'class' => '', 353 | 'id' => '', 354 | ], 355 | 'choices' => [], 356 | 'allow_null' => 0, 357 | 'other_choice' => 0, 358 | 'save_other_choice' => 0, 359 | 'default_value' => '', 360 | 'layout' => 'vertical', 361 | 'return_format' => 'value', 362 | ]); 363 | ``` 364 | [Official Documentation](https://www.advancedcustomfields.com/resources/radio-button) 365 | 366 | #### Button Group 367 | ```php 368 | $builder 369 | ->addButtonGroup('button_group_field', [ 370 | 'label' => 'Button Group Field', 371 | 'instructions' => '', 372 | 'required' => 0, 373 | 'conditional_logic' => [], 374 | 'wrapper' => [ 375 | 'width' => '', 376 | 'class' => '', 377 | 'id' => '', 378 | ], 379 | 'choices' => [], 380 | 'allow_null' => 0, 381 | 'default_value' => '', 382 | 'layout' => 'horizontal', 383 | 'return_format' => 'value', 384 | ]); 385 | ``` 386 | [Official Documentation](https://www.advancedcustomfields.com/resources/button-group/) 387 | 388 | #### True / False 389 | ```php 390 | $builder 391 | ->addTrueFalse('truefalse_field', [ 392 | 'label' => 'True / False Field', 393 | 'instructions' => '', 394 | 'required' => 0, 395 | 'conditional_logic' => [], 396 | 'wrapper' => [ 397 | 'width' => '', 398 | 'class' => '', 399 | 'id' => '', 400 | ], 401 | 'message' => '', 402 | 'default_value' => 0, 403 | 'ui' => 0, 404 | 'ui_on_text' => '', 405 | 'ui_off_text' => '', 406 | ]); 407 | ``` 408 | [Official Documentation](https://www.advancedcustomfields.com/resources/true-false) 409 | 410 | ### Relational 411 | 412 | #### Link 413 | ```php 414 | $builder 415 | ->addLink('link_field', [ 416 | 'label' => 'Link Field', 417 | 'instructions' => '', 418 | 'required' => 0, 419 | 'conditional_logic' => [], 420 | 'wrapper' => [ 421 | 'width' => '', 422 | 'class' => '', 423 | 'id' => '', 424 | ], 425 | 'return_format' => 'array', 426 | ]); 427 | ``` 428 | [Official Documentation](https://www.advancedcustomfields.com/resources/link) 429 | 430 | #### Post Object 431 | ```php 432 | $builder 433 | ->addPostObject('post_object_field', [ 434 | 'label' => 'Post Object Field', 435 | 'instructions' => '', 436 | 'required' => 0, 437 | 'conditional_logic' => [], 438 | 'wrapper' => [ 439 | 'width' => '', 440 | 'class' => '', 441 | 'id' => '', 442 | ], 443 | 'post_type' => [], 444 | 'taxonomy' => [], 445 | 'allow_null' => 0, 446 | 'multiple' => 0, 447 | 'return_format' => 'object', 448 | 'ui' => 1, 449 | ]); 450 | ``` 451 | [Official Documentation](https://www.advancedcustomfields.com/resources/post-object/) 452 | 453 | #### Page Link 454 | ```php 455 | $builder 456 | ->addPageLink('page_link_field', [ 457 | 'label' => 'Page Link Field', 458 | 'type' => 'page_link', 459 | 'instructions' => '', 460 | 'required' => 0, 461 | 'conditional_logic' => [], 462 | 'wrapper' => [ 463 | 'width' => '', 464 | 'class' => '', 465 | 'id' => '', 466 | ], 467 | 'post_type' => [], 468 | 'taxonomy' => [], 469 | 'allow_null' => 0, 470 | 'allow_archives' => 1, 471 | 'multiple' => 0, 472 | ]); 473 | ``` 474 | [Official Documentation](https://www.advancedcustomfields.com/resources/page-link) 475 | 476 | #### Relationship 477 | ```php 478 | $builder 479 | ->addRelationship('relationship_field', [ 480 | 'label' => 'Relationship Field', 481 | 'instructions' => '', 482 | 'required' => 0, 483 | 'conditional_logic' => [], 484 | 'wrapper' => [ 485 | 'width' => '', 486 | 'class' => '', 487 | 'id' => '', 488 | ], 489 | 'post_type' => [], 490 | 'taxonomy' => [], 491 | 'filters' => [ 492 | 0 => 'search', 493 | 1 => 'post_type', 494 | 2 => 'taxonomy', 495 | ], 496 | 'elements' => '', 497 | 'min' => '', 498 | 'max' => '', 499 | 'return_format' => 'object', 500 | ]); 501 | ``` 502 | [Official Documentation](https://www.advancedcustomfields.com/resources/relationship) 503 | 504 | #### Taxonomy 505 | ```php 506 | $builder 507 | ->addTaxonomy('taxonomy_field', [ 508 | 'label' => 'Taxonomy Field', 509 | 'instructions' => '', 510 | 'required' => 0, 511 | 'conditional_logic' => [], 512 | 'wrapper' => [ 513 | 'width' => '', 514 | 'class' => '', 515 | 'id' => '', 516 | ], 517 | 'taxonomy' => 'category', 518 | 'field_type' => 'checkbox', 519 | 'allow_null' => 0, 520 | 'add_term' => 1, 521 | 'save_terms' => 0, 522 | 'load_terms' => 0, 523 | 'return_format' => 'id', 524 | 'multiple' => 0, 525 | ]); 526 | ``` 527 | [Official Documentation](https://www.advancedcustomfields.com/resources/taxonomy) 528 | 529 | #### User 530 | ```php 531 | $builder 532 | ->addUser('user_field', [ 533 | 'label' => 'User Field', 534 | 'instructions' => '', 535 | 'required' => 0, 536 | 'conditional_logic' => [], 537 | 'wrapper' => [ 538 | 'width' => '', 539 | 'class' => '', 540 | 'id' => '', 541 | ], 542 | 'role' => '', 543 | 'allow_null' => 0, 544 | 'multiple' => 0, 545 | ]); 546 | ``` 547 | [Official Documentation](https://www.advancedcustomfields.com/resources/user/) 548 | 549 | ### jQuery 550 | 551 | #### Google Map 552 | ```php 553 | $builder 554 | ->addGoogleMap('google_map_field', [ 555 | 'label' => 'Google Map Field', 556 | 'instructions' => '', 557 | 'required' => 0, 558 | 'conditional_logic' => [], 559 | 'wrapper' => [ 560 | 'width' => '', 561 | 'class' => '', 562 | 'id' => '', 563 | ], 564 | 'center_lat' => '', 565 | 'center_lng' => '', 566 | 'zoom' => '', 567 | 'height' => '', 568 | ]); 569 | ``` 570 | [Official Documentation](https://www.advancedcustomfields.com/resources/google-map) 571 | 572 | #### Date Picker 573 | ```php 574 | $builder 575 | ->addDatePicker('date_picker_field', [ 576 | 'label' => 'Date Picker Field', 577 | 'instructions' => '', 578 | 'required' => 0, 579 | 'conditional_logic' => [], 580 | 'wrapper' => [ 581 | 'width' => '', 582 | 'class' => '', 583 | 'id' => '', 584 | ], 585 | 'display_format' => 'd/m/Y', 586 | 'return_format' => 'd/m/Y', 587 | 'first_day' => 1, 588 | ]); 589 | ``` 590 | [Official Documentation](https://www.advancedcustomfields.com/resources/date-picker) 591 | 592 | #### Date Time Picker 593 | ```php 594 | $builder 595 | ->addDateTimePicker('date_time_picker_field', [ 596 | 'label' => 'Date Time Picker Field', 597 | 'instructions' => '', 598 | 'required' => 0, 599 | 'conditional_logic' => [], 600 | 'wrapper' => [ 601 | 'width' => '', 602 | 'class' => '', 603 | 'id' => '', 604 | ], 605 | ]); 606 | ``` 607 | [Official Documentation](https://www.advancedcustomfields.com/resources/date-time-picker) 608 | 609 | #### Time Picker 610 | ```php 611 | $builder 612 | ->addTimePicker('time_picker_field', [ 613 | 'label' => 'Time Picker Field', 614 | 'instructions' => '', 615 | 'required' => 0, 616 | 'conditional_logic' => [], 617 | 'wrapper' => [ 618 | 'width' => '', 619 | 'class' => '', 620 | 'id' => '', 621 | ], 622 | 'display_format' => 'g:i a', 623 | 'return_format' => 'g:i a', 624 | 'default_value' => '', 625 | ]); 626 | ``` 627 | [Official Documentation](https://www.advancedcustomfields.com/resources/time-picker) 628 | 629 | #### Color Picker 630 | ```php 631 | $builder 632 | ->addColorPicker('color_picker_field', [ 633 | 'label' => 'Color Picker Field', 634 | 'instructions' => '', 635 | 'required' => 0, 636 | 'conditional_logic' => [], 637 | 'enable_opacity' => 0, 638 | 'return_format' => 'string', 639 | 'wrapper' => [ 640 | 'width' => '', 641 | 'class' => '', 642 | 'id' => '', 643 | ], 644 | 'default_value' => '', 645 | ]); 646 | ``` 647 | [Official Documentation](https://www.advancedcustomfields.com/resources/color-picker/) 648 | 649 | ### Layout 650 | 651 | #### Message 652 | ```php 653 | $builder 654 | ->addMessage('message_field', 'message', [ 655 | 'label' => 'Message Field', 656 | 'instructions' => '', 657 | 'required' => 0, 658 | 'conditional_logic' => [], 659 | 'wrapper' => [ 660 | 'width' => '', 661 | 'class' => '', 662 | 'id' => '', 663 | ], 664 | 'message' => '', 665 | 'new_lines' => 'wpautop', // 'wpautop', 'br', '' no formatting 666 | 'esc_html' => 0, 667 | ]); 668 | ``` 669 | 670 | #### Accordion 671 | ```php 672 | $builder 673 | ->addAccordion('accordion_field', [ 674 | 'label' => 'Accordion Field', 675 | 'instructions' => '', 676 | 'required' => 0, 677 | 'conditional_logic' => [], 678 | 'wrapper' => [ 679 | 'width' => '', 680 | 'class' => '', 681 | 'id' => '', 682 | ], 683 | 'open' => 0, 684 | 'multi_expand' => 0, 685 | 'endpoint' => 0, 686 | ]); 687 | 688 | $builder 689 | ->addAccordion('accordion_field_end')->endpoint(); 690 | ``` 691 | [Official Documentation](https://www.advancedcustomfields.com/resources/accordion/) 692 | 693 | #### Tab 694 | ```php 695 | $builder 696 | ->addTab('tab_field', [ 697 | 'label' => 'Tab Field', 698 | 'instructions' => '', 699 | 'required' => 0, 700 | 'conditional_logic' => [], 701 | 'wrapper' => [ 702 | 'width' => '', 703 | 'class' => '', 704 | 'id' => '', 705 | ], 706 | 'default_value' => '', 707 | 'placeholder' => '', 708 | 'prepend' => '', 709 | 'append' => '', 710 | 'maxlength' => '', 711 | 'placement' => '', 712 | ]); 713 | ``` 714 | [Official Documentation](https://www.advancedcustomfields.com/resources/tab/) 715 | 716 | #### Group 717 | ```php 718 | $builder 719 | ->addGroup('group_field', [ 720 | 'label' => 'Group Field', 721 | 'instructions' => '', 722 | 'required' => 0, 723 | 'conditional_logic' => [], 724 | 'wrapper' => [ 725 | 'width' => '', 726 | 'class' => '', 727 | 'id' => '', 728 | ], 729 | 'layout' => 'block' 730 | ]) 731 | ->addText('sub_field') 732 | ->endGroup(); 733 | ``` 734 | [Official Documentation](https://www.advancedcustomfields.com/resources/group/) 735 | 736 | #### Repeater 737 | ```php 738 | $builder 739 | ->addRepeater('repeater_field', [ 740 | 'label' => 'Repeater Field', 741 | 'instructions' => '', 742 | 'required' => 0, 743 | 'conditional_logic' => [], 744 | 'wrapper' => [ 745 | 'width' => '', 746 | 'class' => '', 747 | 'id' => '', 748 | ], 749 | 'collapsed' => '', 750 | 'min' => 0, 751 | 'max' => 0, 752 | 'layout' => 'table', 753 | 'button_label' => '', 754 | 'sub_fields' => [], 755 | ]); 756 | ``` 757 | [Official Documentation](https://www.advancedcustomfields.com/resources/repeater/) 758 | 759 | #### Flexible Content 760 | ```php 761 | $builder 762 | ->addFlexibleContent('flexible_content_field', [ 763 | 'instructions' => '', 764 | 'required' => 0, 765 | 'conditional_logic' => [], 766 | 'wrapper' => [ 767 | 'width' => '', 768 | 'class' => '', 769 | 'id' => '', 770 | ], 771 | 'button_label' => 'Add Row', 772 | 'min' => '', 773 | 'max' => '', 774 | ]); 775 | 776 | $builder 777 | ->addLayout('layout', [ 778 | 'label' => 'Layout', 779 | 'display' => 'block', 780 | 'sub_fields' => [], 781 | 'min' => '', 782 | 'max' => '', 783 | ]); 784 | 785 | $builder 786 | ->addLayout(new FieldsBuilder()); 787 | ``` 788 | [Official Documentation](https://www.advancedcustomfields.com/resources/flexible-content/) 789 | 790 | ## Configuration 791 | 792 | ### Composing Fields 793 | ```php 794 | $builder 795 | ->addFields(new FieldsBuilder()); 796 | 797 | $builder 798 | ->addField('text', 'title') 799 | ->setKey('field_title') 800 | ->setLabel('My Label') 801 | ->setDefaultValue('Lorem ipsum') 802 | ->setInstructions('This is a title.') 803 | ->setRequired() 804 | ->setUnrequired() 805 | ->setConfig('placeholder', 'Enter the title'); 806 | ``` 807 | 808 | ### Composing Custom/3rd Party Addon Fields 809 | 810 | Add any other registered custom/[3rd party ACF Fields](https://www.advancedcustomfields.com/add-ons/) using the `addField($name, $type, $args)` method. 811 | 812 | ```php 813 | $builder 814 | ->addFields(new FieldsBuilder()); 815 | 816 | $builder 817 | ->addField('icon', 'font-awesome') 818 | ->setLabel('My Icon') 819 | ->setInstructions('Select an icon') 820 | ->setConfig('save_format', 'class') 821 | ``` 822 | 823 | ### Modifying Fields 824 | ```php 825 | $builder 826 | ->modifyField('title', ['label' => 'Modified Title']); 827 | 828 | $builder 829 | ->addFields(new FieldsBuilder()) 830 | ->getField('title') 831 | ->modifyField('title', ['label' => 'Modified Title']); 832 | ``` 833 | 834 | ### Removing Fields 835 | ```php 836 | $builder 837 | ->removeField('title'); 838 | ``` 839 | 840 | ### Field Choices 841 | ```php 842 | $builder 843 | ->addChoice('red') 844 | ->addChoice('blue') 845 | ->addChoice('green'); 846 | 847 | $builder 848 | ->addChoices(['red' => 'Red'], ['blue' => 'Blue'], ['green' => 'Green']); 849 | ``` 850 | 851 | ### Field Conditions 852 | ```php 853 | $builder 854 | ->conditional('true_false', '==', '0') 855 | ->and('true_false', '!=', '1') 856 | ->or('false_true', '==', '1'); 857 | ``` 858 | 859 | ### Field Wrapper 860 | ```php 861 | $builder 862 | ->setWidth('30'); 863 | 864 | $builder 865 | ->setSelector('.field') 866 | ->setSelector('#field'); 867 | 868 | $builder 869 | ->setAttr('width', '30') 870 | ->setAttr('class', 'field') 871 | ->setAttr('id', 'field'); 872 | 873 | $builder 874 | ->setWrapper(['width' => '30', 'class' => 'field', 'id' => 'field']); 875 | ``` 876 | 877 | ### Field Group Location 878 | 879 | ```php 880 | $builder 881 | ->setLocation('post_type', '==', 'page') 882 | ->and('page_type', '==', 'front_page'); 883 | ``` 884 | 885 | #### Field Group Locations 886 | 887 | * **Post**: `post_type`, `post_type_list`, `post_type_archive`, `post_template`, `post_status`, `post_format`, `post_category`, `post_taxonomy`, `post` 888 | * **Page**: `page_template`, `page_type`, `page_parent`, `page` 889 | * **User**: `current_user`, `current_user_role`, `user_form`, `user_role` 890 | * **Forms**: `taxonomy`, `taxonomy_list`, `attachment`, `comment`, `widget`, `nav_menu`, `nav_menu_item`, `block`, `options_page` 891 | * **Custom**: [Official Documentation](https://www.advancedcustomfields.com/resources/custom-location-rules/) 892 | 893 | ### Field Group Position 894 | ```php 895 | $builder = new FieldsBuilder('banner', ['position' => 'side']); // acf_after_title, normal, side 896 | ``` 897 | --------------------------------------------------------------------------------