Support

Account

Home Forums Add-ons Repeater Field Hook to force repeater rows collapse on load Reply To: Hook to force repeater rows collapse on load

  • Hi @jostrander

    I believe you can use the acf/input/admin_footer hook to add the collapse class to the field. It should be something like this:

    function my_acf_admin_footer() {
    	?>
    	<script type="text/javascript">
        (function($) {
            
            $(document).ready(function(){
                
                $('.acf-field-1234567890 .acf-row').addClass( "-collapsed" );
                $('.acf-field-1234567890 .acf-field-abcdefghijklm').addClass( "-collapsed-target" );
                $('.acf-field-1234567890 .acf-field-abcdefghijklm').attr( "colspan", "2" );
                
            });
            
        })(jQuery);    
        </script>
    	<?php
    }
    add_action('acf/input/admin_footer', 'my_acf_admin_footer');

    Where “1234567890” is the field key of your repeater field and “abcdefghijklm” is the field key of the subfield you want to show.

    I hope this helps. Thanks!