Since version: v1.8.0
Filter formatting area_covers
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.
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.