Support

Account

Home Forums Backend Issues (wp-admin) ACF Accordion, Displaying a value of a specific text field Reply To: ACF Accordion, Displaying a value of a specific text field

  • I solved this with the following JS:

    $( document ).ready(function() {
    
        dynamic_title_repeater_accordion('repeater_name_here', 'field_name_here');
    
    });
    
    function dynamic_title_repeater_accordion(repeater_name, field_name) {
        var information_tabs = $("div[data-name='" + repeater_name + "']");
        if (information_tabs.length) {
            var selector = "tr:not(.acf-clone) td.acf-fields .acf-accordion-content div[data-name='" + field_name + "'] input";
    
            // add lister
            $(information_tabs).on('input', selector, function() {
                var me = $(this);
                me.closest('td.acf-fields').find('.acf-accordion-title label').text(me.val());
            });
    
            // trigger the function on load
            information_tabs.find(selector).trigger('input');
    
        }
    }

    To include the JS file in the admin backend, in functions.php add this and change the path to the JS file:

    function acf_admin_enqueue_script($hook) {
        if ('post.php' !== $hook) {
            return;
        }
        wp_enqueue_script('admin-js', 'path_to/admin.js');
    }
    
    add_action('admin_enqueue_scripts', 'acf_admin_enqueue_script');