Releases: StoutLogic/acf-builder
Modify / Remove Nested Fields
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
Fix PHP Stan errors, php clone functionality
Merged in some PRs: #133 and #137
Thanks @titouanmathis and @davddo
Conditionals referencing parent fields
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:
- #130 Fix Intelephense's Undefined method
- Setup testing via GitHub actions for php versions 5.4 - 7.4. The version of PHP unit being used isn't supported for PHP 8.0 so it is untested. If you run into any issues in the wild, while testing on 8.0, let me know.
Add support for doctrine/inflector ^2.0
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 !
Add `setLabel` helper
Allows you to use ->setLabel('My Custom Label')
on a FieldBuilder. Thanks @Log1x and sorry for the delay.
Allow use of other doctrine library versions
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 !!
Field Wrapper Methods
@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.
Fix dependancies
1.7.2 Remove version from composer.json and change doctrine inflector patch…
Remove composer.lock file
Merge pull request #68 from kenvunz/master Remove `composer.lock`
Added Button Group Field
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!