Open joseph-farruggio opened 1 year ago
Hey @joseph-farruggio I agree the docs probably aren't clear on this, but I tried your example using ad_title
as the collapsed key and it worked for me. But maybe in your more complicated example there is another issue?
/**
* Subfield template
*/
$ad_set = new FieldsBuilder('ad_set');
$ad_set
->addTab('ad_content')
->addText('ad_title', ['wrapper' => ['width' => '50%']]);
/**
* Field group with repeater
*/
$wp_custom_ads = new FieldsBuilder('wp_custom_ads');
$wp_custom_ads
->addRepeater(
'priority_ads',
['layout' => 'block', 'button_label' => 'New Ad', 'collapsed' => 'ad_title']
)
->addFields($ad_set)
->setLocation('options_page', '==', 'wp-custom-ads');
add_action('acf/init', function () use ($wp_custom_ads) {
acf_add_local_field_group($wp_custom_ads->build());
});
That works, thanks!
Based on the docs, I thought it had to be prepended with field_
.
I have a repeater
priority_ads
and I want the collapsed value to be thead_title
subfield's key. I'm having trouble determining the field's key. The field is added to the repeater using addFields().I've tried multiple variations of field keys using these docs: https://github.com/StoutLogic/acf-builder/wiki/generated-keys https://github.com/StoutLogic/acf-builder/wiki/composing-fields#generated-keys
I get an error each time that the field (based on the key I provided) does not exist.
I've created a simplified version of my implementation: