F
Filament2mo ago
Nedwor

Filament Exporter : How to custom the columns selection modal ?

Hello everyone, I'm trying to custom this magnificent modal from Filament exporter. But I struggle to make it work. Is it even possible ? I'm trying to do something like this, using getOptionsFormComponents() and putting ->columnMapping(false) on my exporter
public static function getOptionsFormComponents(): array
{
// Get all columns for the export
$columns = self::getColumns();
$columnOptions = collect($columns)->mapWithKeys(function (ExportColumn $column) {
return [$column->getName() => $column->getLabel()];
})->toArray();

return [
Forms\Components\Section::make('Export Options')
->schema([
TextInput::make('file_name')
->label('File name')
->default('beneficiaries_export')
->required()
->maxLength(255)
->columnSpanFull(),

Forms\Components\CheckboxList::make('columns')
->label('Select columns to export')
->options($columnOptions)
->columns(3)
->gridDirection('row')
->bulkToggleable()
->default(array_keys($columnOptions))
])
->columns(1)
];
}
public static function getOptionsFormComponents(): array
{
// Get all columns for the export
$columns = self::getColumns();
$columnOptions = collect($columns)->mapWithKeys(function (ExportColumn $column) {
return [$column->getName() => $column->getLabel()];
})->toArray();

return [
Forms\Components\Section::make('Export Options')
->schema([
TextInput::make('file_name')
->label('File name')
->default('beneficiaries_export')
->required()
->maxLength(255)
->columnSpanFull(),

Forms\Components\CheckboxList::make('columns')
->label('Select columns to export')
->options($columnOptions)
->columns(3)
->gridDirection('row')
->bulkToggleable()
->default(array_keys($columnOptions))
])
->columns(1)
];
}
But it seems that ->columnMapping(false) completely overtake the column selection ? Because, with this method, I get a beautiful column selection but end up with a full export, meaning every columns are exported.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?