An Advanced Custom Field Configuration Builder
GPL-2.0 License
Bot releases are hidden (Show)
A frequent requested feature was the ability to modify and remove nested fields. This is now possible with adding the getField
method to the GroupBuilder and getLayout
to the FlexibleContentBuilder. Also introduced is a short hand so you don't have to chain getField
calls. Using the ->
delimiter you can directly reach the field you're right to modify or remove.
Example:
$builder->removeField('sections->hero->sub_title');
There was discussion of using a .
dot delimiter instead for the short hand, but I decided to use the arrow in case people had used a .
in their existing field names. I didn't want them to experience unintended consequences. When releasing a major version with breaking changes we will revisit this possibility.
Check out the docs for it here: https://github.com/StoutLogic/acf-builder/wiki/modifying-fields#modifying-nested-fields
Thanks @Androlax2 @voyou-sbeaulieu @marcelo2605 for your contributions and patience
Published by stevep over 3 years ago
Merged in some PRs: #133 and #137
Thanks @titouanmathis and @davddo
Published by stevep over 3 years ago
You can now write conditionals that reference fields not on the same level. [Issue: #52]
You can either just reference the name of the parent field:
$builder = new \StoutLogic\AcfBuilder\FlexibleContentBuilder('sections');
$builder
->addLayout('hero')
->addSelect('hero_type')
->addChoices('fullscreen', 'standard')
->addImage( 'hero_image' )
->addWysiwyg( 'hero_text' )
->addRepeater('cta')
->addSelect('link_type')
->addChoices('internal', 'external', 'text')
->addTrueFalse('cta_animated')
->conditional('hero_type', '==', 'fullscreen');
Or you can set a custom key
$builder = new \StoutLogic\AcfBuilder\FlexibleContentBuilder('sections');
$builder
->addLayout('hero')
->addSelect('hero_type')
->addChoices('fullscreen', 'standard')
->setCustomKey('my_custom_key')
->addImage( 'hero_image' )
->addWysiwyg( 'hero_text' )
->addRepeater('cta')
->addSelect('link_type')
->addChoices('internal', 'external', 'text')
->addTrueFalse('cta_animated')
->conditional('my_custom_key', '==', 'fullscreen');
This shouldn't break backwards compatibility, I've tested it on my professional projects. But if you do run into issues, let me know ASAP.
Other additions include:
Published by stevep over 4 years ago
Add support for doctrine/inflector ^2.0 and some code cleanup, while maintaining backwards compatibility with Add support for doctrine/inflector ^1.1 and older versions of PHP
Thanks @Log1x !
Published by stevep almost 5 years ago
Allows you to use ->setLabel('My Custom Label')
on a FieldBuilder. Thanks @Log1x and sorry for the delay.
Published by stevep almost 5 years ago
ACF Builder relies on
"doctrine/inflector": "^1.1",
"doctrine/instantiator": "^1.0"
And now will allow newer 1.x versions to be installed along site ACF Builder. Thanks @guix77 !!
Published by stevep about 6 years ago
@aprokopenko has graciously added function calls to make setting field width, class, id and attributes much easier.
$builder = new FieldsBuilder('Slider')
$builder
->addText( 'slider_title' )
->setWidth( '50%' )
->setSelector( '#my-id.my-class' )
->setAttr( 'data-custom_attr', 'thisisattr' );
No more need to manually set the wrapper array as attributes to a new field.
Published by stevep about 6 years ago
Published by stevep about 6 years ago
Published by stevep about 6 years ago
You can use $fieldsBuilder->addButtonGroup
like you would select or radio buttons. See ACF documentation for more information about Button Groups
Thanks @Log1x for the help!
Published by stevep over 6 years ago
Fixed issues #58 and #59
Published by stevep almost 7 years ago
Added the new ACF Accordion field. Must be using ACF 5.6.6 to use it.
It works just like Tab field but includes two additional methods setOpen()
and setMultiExpand()
. true
or false
can be passed as a parameter, true
is default.
$fieldgroup = new FieldsBuilder('group');
$fieldgroup
->addAccordion('content')
->setOpen()
->addWysiwyg('content')
->addAccordion('background')
->addImage('background_image')
->addColorPicker('background_color');
Published by stevep about 7 years ago
addRange
methodmodifyField
modifyField
documentation to explicitly say the passed closure needs to return a FieldsBuilder
Published by stevep about 7 years ago
Add new ACF fields addLink
and addGroup
. A group is treated just like a repeater, but instead of an endRepeater
function, there is an endGroup
function.
I'm releasing this before a refactor, which the code needs, because I wanted to get the functionality out there for everyone. I'm not happy with all of the inheritance, and I'm not longer happy with the confusing names FieldsBuilder
vs FieldBuilder
vs GroupBuilder
Also I would like to use less magic methods if possible. Perhaps in a 2.0 release.
Published by stevep almost 8 years ago
Published by stevep almost 8 years ago
Lots of internal changes, uses an array FieldBuilder objects to story field configs instead of storing field group's field config in a simple array.
getRootContext
to get the top level parentContext
fieldsBuilder
in a RepeaterBuilder
protected so sub classes can access itgetGroupConfig
function to FieldsBuilder
fieldExists
method to FieldsBuilder
addPostLink
to addPageLink
on FieldsBuilder
Published by stevep over 8 years ago
Moved tests to autoload-dev so they aren't included in production. Issue #18
Updated composer dependencies.
Published by stevep over 8 years ago
Modifying and Removing Fields
Added is the ability to modify, insert and remove fields from a FieldsBuilder. See the Modifying Fields page in the wiki for more information.
Issue #12
Added addTimePicker and addDateTimePicker function
ACF 5.3.9 added these two new fields
Issue #13
Published by stevep over 8 years ago
Fixes #8 #11
Published by stevep over 8 years ago
Resolves issues #2 and #6
Fixes the setLocation bug. When setLocation is called on a builder, it will call it on the parent builder context if one exists.
To use the library without composer, simply require the included autoload.php file.