Home › Forums › ACF PRO › Dynamically creating field based on select value › Reply To: Dynamically creating field based on select value
So i exported the field group with it’s conditional wysywig field based on the choice in the button group to php:
if (function_exists('acf_add_local_field_group')) :
acf_add_local_field_group(array(
'key' => 'group_xxxxxxxxxx',
'title' => 'The product tabs',
'fields' => array(
array(
'key' => 'field_of_the_product_tabs_xxxxx',
'label' => 'The tabs',
'name' => 'the_tabs',
'type' => 'button_group',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
// These choices are generated by the repeater with a text subfield from the option page
'choices' => array(
'choice1' => 'choice1',
'choice2' => 'choice2',
),
'allow_null' => 0,
'default_value' => '',
'layout' => 'horizontal',
'return_format' => 'value',
),
// So this wysywig field needs to be created everytime a choice is added from the option page
// Corresponding to the selected button group choice
array(
'key' => 'field_xxxxxxxx',
'label' => 'product tab content',
'name' => 'pro_tab_content',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
// array van conditional logic ie.
'conditional_logic' => array(
array(
array(
'field' => 'field_of_the_product_tabs_xxxxx',
'operator' => '==',
'value' => 'choice1', // the selected button group choice ie. choice1, choice2...
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
'delay' => 0,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'product',
),
),
),
));
endif;
I think i’m missing some skills or knowledge because i can’t wrap my head around in how to create a wysiwyg field specific for it’s product tab.
A ‘static’ field and displaying that in the tab content is easy, but then every tab has the same value 😉
/* --
WooCommerce Tabs content
-- */
function woo_tab_content($slug, $tab)
{
// the content in this function is display in the WooCommerce tabs
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.