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');
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.