Hi,
i tried registering fields based on the returned value of already registered fields. I was not able to do so, since i later noticed acf-composer uses the init action hook. I did not dig very deep into the code, but it should be save to simply switch the hook to the acf/init hook that is also used throughout the acf documentation.
I did a small test and switched the action locally. Everything worked as expected. However, I noticed that once I call the get_field() function the field group get no longer added.
Example code:
namespace App\Fields;
use Log1x\AcfComposer\Field;
use StoutLogic\AcfBuilder\FieldNameCollisionException;
use StoutLogic\AcfBuilder\FieldsBuilder;
class Products extends Field
{
/**
* The field group.
*
* @return array
* @throws FieldNameCollisionException
*/
public function fields(): array
{
$products = new FieldsBuilder('products');
$field_name = get_field( 'attribute_name', 1234);
$products
->addText($field_name);
$products
->setLocation('post_type', '==', PRODUCTS_PT)
->or('post_type', '==', PRODUCTS_STAGED_PT);
return $products->build();
}
}
Hi, i tried registering fields based on the returned value of already registered fields. I was not able to do so, since i later noticed acf-composer uses the init action hook. I did not dig very deep into the code, but it should be save to simply switch the hook to the acf/init hook that is also used throughout the acf documentation.
I did a small test and switched the action locally. Everything worked as expected. However, I noticed that once I call the
get_field()
function the field group get no longer added.Example code: