Support

Account

Home Forums Add-ons Repeater Field Collapse specific Repeater fields by default

Helping

Collapse specific Repeater fields by default

  • Hi, I know this topics has passed before but I would like to know how to collapse specific groups of repeater fields by default.. I have this snipped which closes all repeater fields.
    Any thoughts on this? Thanks in advance.

    // Collapse ACF Repeater by default
    add_action('acf/input/admin_head', 'wpster_acf_repeater_collapse');
    function wpster_acf_repeater_collapse() {
    ?>
    <style id="wpster-acf-repeater-collapse">.acf-repeater .acf-table {display:none;}</style>
    <script type="text/javascript">
    	jQuery(function($) {
    		$('.acf-repeater .acf-row').addClass('-collapsed');
    		$('#wpster-acf-repeater-collapse').detach();
    	});
    </script>
    <?php
    }
  • You would need to target the specific rows. For example:

    
    // target all except 1st row
    $('.acf-repeater .acf-row+.acf-row').addClass('-collapsed');
    

    More than this I’d need more specifics on what your criteria is for collapsing a row.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Collapse specific Repeater fields by default’ is closed to new replies.