\Dewdrop\Fields\HelperCsvCell

The CsvCell helper actually composes 2 simpler helpers that are useful when customizing the rendering of a CSV export:

  1. CsvCell.Content: This helper will allow you to customize the content of your CSV export's data rows.

  2. CsvCell.Header: This helper allows you to customize the content of your CSV export's header row, if you want to display anything other than just the field's labels.

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

$renderer = $this->csvCellRenderer();

$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(
            'CsvCell:Header',
            function ($helper, $field) {
                return 'Return a custom string rather than using the field label';
            }
        );
    }
);

Summary

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

Properties

Methods

__construct()

__construct() : void

Creates header and content cell helpers

getContentRenderer()

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

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

Returns

\Dewdrop\Fields\Helper\CsvCell\Content

getHeaderRenderer()

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

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

Returns

\Dewdrop\Fields\Helper\CsvCell\Header