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 area_covers

New since version 1.8.0

This filter is new.

This filter decides whether a formatting area covers a cell in the table editor. It is the JavaScript counterpart of the covers entry of an area in the PHP filter acf_tablefield/formatting/areas. The PHP function only runs on the website, so the table editor needs this filter to show the same cells as formatted.

The filter runs for every area and gets the result of the check of the area as covers. That is the result of its entries sections, columns and table_options. Without a filter, the editor uses that result. An area that has a PHP covers function is marked with param.area.covers === true.

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 entry covers of the area, see acf_tablefield/formatting/areas. To get the same look in the editor and on the website, set both the same way.

Example

ACFTableFieldPro.core.addFilter( 'formatting', 'area_covers', function( covers, param ) { 
 
	/* 
	param = { 
		area: {}, // the area, area.key is the key, area.covers is true for an area with a PHP covers function 
		table: {}, // the table object, only set if the caller passes it 
		tableOpts: {}, // the options of the table 
		sectionKey: 'b', // h, b or f 
		rowIndex: 0, // row index within the section, starting at 0 
		colIndex: 0, // column index, starting at 0, -1 for a whole row 
	} 
	*/ 
 
	if ( param.area.key !== 'zb' ) { 
 
		return covers; 
	} 
 
	// every second row of the body, the same rule as the PHP function 
	return param.sectionKey === 'b' && param.rowIndex % 2 === 1; 
} );

covers is a boolean. Return a boolean. param.rowIndex and param.colIndex start at 0 like the indexes of the PHP function. param.colIndex is -1 when the editor asks for the areas of a whole row, for example for the controls of a row. An area that depends on the column should return false for -1, as an area of one column cannot cover a whole row. param.table is not set by every caller, check it before you use it.

Previous and Next Sources

Parent sources