count($field['value']) ) { for( $i = 0; $i < $field['row_min']; $i++ ) { // already have a value? continue... if( isset($field['value'][$i]) ) { continue; } // populate values $field['value'][ $i ] = array(); foreach( $field['sub_fields'] as $sub_field) { $sub_value = false; if( !empty($sub_field['default_value']) ) { $sub_value = $sub_field['default_value']; } $field['value'][ $i ][ $sub_field['key'] ] = $sub_value; } } } // max rows $row_count = count($field['value']); if( $row_count > $field['row_limit'] ) { for( $i = 0; $i < $row_count; $i++ ) { if( $i >= $field['row_limit'] ) { unset( $field['value'][ $i ] ); } } } // setup values for row clone $field['value']['acfcloneindex'] = array(); foreach( $field['sub_fields'] as $sub_field ) { $sub_value = false; if( isset($sub_field['default_value']) ) { $sub_value = $sub_field['default_value']; } $field['value']['acfcloneindex'][ $sub_field['key'] ] = $sub_value; } // helper function which does not exist yet in acf if( !function_exists('acf_get_join_attr') ): function acf_get_join_attr( $attributes = false ) { // validate if( empty($attributes) ) { return ''; } // vars $e = array(); // loop through and render foreach( $attributes as $k => $v ) { $e[] = $k . '="' . esc_attr( $v ) . '"'; } // echo return implode(' ', $e); } endif; if( !function_exists('acf_join_attr') ): function acf_join_attr( $attributes = false ) { echo acf_get_join_attr( $attributes ); } endif; ?>