filament-export icon indicating copy to clipboard operation
filament-export copied to clipboard

strip_tags for CSV headers

Open shopapps opened this issue 1 year ago • 0 comments

I have created a pull request for this, but i noticed if the label for a column contains HTML this gets passed into the CSV.

editing line 133 of FilamentExport.phpand adding strip_tags helps stop this:

    $headers = $this->getAllColumns()->map(fn ($column) => strip_tags($column->getLabel()))->toArray();

In the PR i also added the option to request $state to receive the original value of a given row when using (see README.md for examples)

FilamentExportHeaderAction::make('export')->label(__('Export'))
                    ->formatStates([
                        'last_name'   => fn(string $state) :string => $state,  // returns raw value
]);

shopapps avatar Jan 24 '24 12:01 shopapps