\Dewdrop\Fields\HelperTableCell

The TableCell helper actually composes 3 simpler helpers that are useful when customizing the rendering an HTML table:

  1. TableCell.Content: This helper will allow you to customize the content of your table's <td> tags.

  2. TableCell.Header: This helper allows you to customize the content of your table's <th> tags, if you want to display anything other than just the field's labels.

  3. TableCell.TdClassNameRenderer: This helper allows you to add one or more classes to your table's <td> tags.

Customizing the rendering of your cell's content in a view script:

$renderer = $this->tableCellRenderer();

$renderer->getContentRenderer()->assign(
    'my_table_name:my_field',
    function ($helper, array $rowData, $rowIndex, $columnIndex) {
        return $helper->getEscaper()->escapeHtml($rowData['my_field']);
    }
);

Customizing the rendering of a header in your model (typically in the init() method of a \Dewdrop\Db\Table sub-class):

$this->customizeField(
    'my_field',
    function ($field) {
        $field->assignHelperCallback(
            'TableCell:Header',
            function ($helper, $field) {
                return 'Return a custom string rather than using the field label';
            }
        );
    }
);

Summary

Methods
Properties
Constants
__construct()
getContentRenderer()
getHeaderRenderer()
getTdClassNamesRenderer()
setRowClassCallback()
getRowClasses()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$contentRenderer
$headerRenderer
$tdClassNamesRenderer
$rowClassCallback
N/A

Properties

$rowClassCallback

$rowClassCallback : callable

A callback used to get an array of CSS class name for a table row.

Type

callable

Methods

__construct()

__construct(\Dewdrop\View\View  $view) 

Provide a \Dewdrop\View\View hat can be used by callbacks to escape their output to prevent XSS attacks or call helpers to render their output.

Parameters

\Dewdrop\View\View $view

getContentRenderer()

getContentRenderer() : \Dewdrop\Fields\Helper\TableCell\Content

Get the content renderer so you can assign custom callbacks or render your table.

Returns

\Dewdrop\Fields\Helper\TableCell\Content

getHeaderRenderer()

getHeaderRenderer() : \Dewdrop\Fields\Helper\TableCell\Header

Get the header renderer so you can assign custom callbacks or render your table headers.

Returns

\Dewdrop\Fields\Helper\TableCell\Header

getTdClassNamesRenderer()

getTdClassNamesRenderer() : \Dewdrop\Fields\Helper\TableCell\TdClassNames

Get the TD class names renderer so you can assign custom callbacks and generate class strings.

Returns

\Dewdrop\Fields\Helper\TableCell\TdClassNames

setRowClassCallback()

setRowClassCallback(callable  $callback) : $this

Provide a callback that can be used to generate an array of CSS class names that should be applied to a table row.

Parameters

callable $callback

Returns

$this

getRowClasses()

getRowClasses(array  $rowData) : array

Get an array of CSS class names that should be applied to the given row.

Parameters

array $rowData

Returns

array