Closed marcelo2605 closed 3 years ago
You could save the field, or conditional to a variable and then add more conditionals to that. Basically since every function call in ACF Builder's fluent api return $this
, you can grab a handle at any point.
So something like this should work.
$builder = new FieldsBuilder('banner');
$builder
->addText('Title');
$filterTaxonomyField = $builder->addTrueFalse('filter_taxonomy', [
'label' => 'Filter by taxonomy?',
'wrapper' => [
'width' => '33%',
],
'ui' => 1,
]);
foreach($condition in $conditions) {
$filterTaxonomyField
->conditional($condition, '==', '1');
}
return $builder->build();
Thanks @stevep!
I'm not sure if it's possible, but I'm trying to figure out how to set some conditions from an array of values.
So basically I have a first condition and need to add some other "and" conditions where the values comes from a function.