Home › Forums › Feature Requests › Repeater Field Copier › Reply To: Repeater Field Copier
Hi @codydoodle
I believe you can do it by using custom Javascript. Here’s an example how to do it:
function my_acf_repeater_clone() {
?>
<script type="text/javascript">
(function($) {
acf.add_action('append', function( el ){
// $el will be equivalent to the new element being appended $('tr.row')
// Cache the previous row first
var prevField = el.prev();
// Get the value for certain field
var prevFieldValue = prevField.find(".acf-field-1234567890abc input").val();
// Set it to the new row
el.find(".acf-field-1234567890abc input").val(prevFieldValue);
});
})(jQuery);
</script>
<?php
}
add_action('acf/input/admin_footer', 'my_acf_repeater_clone');
Please keep in mind that you need to target the class based on the field key.
I hope this helps 🙂
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.