field = $field; $this->sub_fields = $field['sub_fields']; // Default to non-paginated repeaters. if ( empty( $this->field['pagination'] ) ) { $this->field['pagination'] = false; } // We don't yet support pagination inside other repeaters or flexible content fields. if ( ! empty( $this->field['parent_repeater'] ) || ! empty( $this->field['parent_layout'] ) ) { $this->field['pagination'] = false; } // We don't yet support pagination in frontend forms or inside blocks. if ( ! is_admin() || acf_get_data( 'acf_inside_rest_call' ) || doing_action( 'wp_ajax_acf/ajax/fetch-block' ) ) { $this->field['pagination'] = false; } $this->setup(); } /** * Sets up the field for rendering. * * @since 6.0.0 * * @return void */ private function setup() { if ( $this->field['collapsed'] ) { foreach ( $this->sub_fields as &$sub_field ) { // Add target class. if ( $sub_field['key'] == $this->field['collapsed'] ) { $sub_field['wrapper']['class'] .= ' -collapsed-target'; } } } if ( $this->field['max'] ) { // If max 1 row, don't show order. if ( 1 == $this->field['max'] ) { $this->show_order = false; } // If max == min, don't show add or remove buttons. if ( $this->field['max'] <= $this->field['min'] ) { $this->show_remove = false; $this->show_add = false; } } if ( empty( $this->field['rows_per_page'] ) ) { $this->field['rows_per_page'] = 20; } if ( (int) $this->field['rows_per_page'] < 1 ) { $this->field['rows_per_page'] = 20; } $this->value = $this->prepare_value(); } /** * Prepares the repeater values for rendering. * * @since 6.0.0 * * @return array */ private function prepare_value() { $value = is_array( $this->field['value'] ) ? $this->field['value'] : array(); if ( empty( $this->field['pagination'] ) ) { // If there are fewer values than min, populate the extra values. if ( $this->field['min'] ) { $value = array_pad( $value, $this->field['min'], array() ); } // If there are more values than max, remove some values. if ( $this->field['max'] ) { $value = array_slice( $value, 0, $this->field['max'] ); } } $value['acfcloneindex'] = array(); return $value; } /** * Renders the full repeater table. * * @since 6.0.0 * * @return void */ public function render() { // Attributes for main wrapper div. $div = array( 'class' => 'acf-repeater -' . $this->field['layout'], 'data-min' => $this->field['min'], 'data-max' => $this->field['max'], 'data-pagination' => ! empty( $this->field['pagination'] ), ); if ( $this->field['pagination'] ) { $div['data-per_page'] = $this->field['rows_per_page']; $div['data-total_rows'] = $this->field['total_rows']; $div['data-orig_name'] = $this->field['orig_name']; } if ( empty( $this->value ) ) { $div['class'] .= ' -empty'; } ?>
> $this->field['name'], 'value' => '', 'class' => 'acf-repeater-hidden-input', ) ); ?> thead(); ?> rows(); ?>
table_actions(); ?>
field['layout'] ) { return; } ?> show_order ) : ?> sub_fields as $sub_field ) : // Prepare field (allow sub fields to be removed). $sub_field = acf_prepare_field( $sub_field ); if ( ! $sub_field ) { continue; } // Define attrs. $attrs = array( 'class' => 'acf-th', 'data-name' => $sub_field['_name'], 'data-type' => $sub_field['type'], 'data-key' => $sub_field['key'], ); if ( $sub_field['wrapper']['width'] ) { $attrs['data-width'] = $sub_field['wrapper']['width']; $attrs['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;'; } // Remove "id" to avoid "for" attribute on