ACF Table Field Pro Add-on Docs Last updated:

Parent sources

On this page

Since version: v1.8.0

Release Candidate 1.8.0-RC1

This page documents version 1.8.0, which is available as Release Candidate 1.8.0-RC1 for manual installation. The current public version is 1.7.6, automatic plugin updates still deliver that version.

Download the Release Candidate from your account (Download the plugin) and install it manually (Install the plugin). Details may still change until the final release.

Filter formatting cell_tokens

New since version 1.8.0

This filter is new.

This filter changes the formatting tokens of a data cell in the table editor. It is the JavaScript counterpart of the PHP filter acf_tablefield/formatting/cell_tokens. It runs after the tokens of the cell are resolved from the cell, row, column, area and table options. The table editor sets the result as the attribute data-acftf-format of the cell.

Set the PHP and the JavaScript filter the same way

This filter changes the table editor in the WordPress admin. The table output on the website is changed by the PHP filter acf_tablefield/formatting/cell_tokens. To get the same look in the editor and on the website, set both filters the same way.

ACFTableFieldPro.core.addFilter( 'formatting', 'cell_tokens', function( tokens, param ) { 
 
	/* 
	param = { 
		table: {}, // the table object 
		cell: $td, // the jQuery object of the cell 
		sectionKey: 'b', // h, b or f 
		rowIndex: 0, // row index within the section, starting at 0 
		colIndex: 0, // column index, starting at 0 
	} 
	*/ 
 
	// replace the token for the font weight 700 with an own token 
	return tokens.map( function( token ) { 
 
		return token === 'fw-700' ? 'fw-heavy' : token; 
	} ); 
} );

tokens is an array of strings. param.rowIndex and param.colIndex start at 0 like the indexes in the PHP filter. The column index is the physical one: it also counts cells that are hidden by a span.

Previous and Next Sources

Parent sources