Support

Account

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
    
    }