You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This prevents developers from easily overriding or extending the allowed MIME types for the CSV import. For example, some systems, browsers, or operating systems might identify CSV files with slightly different or obscure MIME types, and developers cannot add them without entirely overriding the $action->schema([...]), which is very cumbersome as it requires duplicating the internal CSV parsing logic present in the original setUp() method.
Describe the solution you'd like
It would be extremely helpful to introduce a property and setter/getter methods for acceptedFileTypes within the ImportAction class so it can be customized fluently.
Overriding the schema(): We can call ->schema([...]) on the ImportAction, but this involves copying a massive chunk of logic handling the CSV chunking and parsing directly into the resource file, which defeats the purpose of having a pre-built action.
Subclassing ImportAction: We can create a custom CustomImportAction extends ImportAction and override setUp(). However, this again requires copying the entire setup block just to change one line of code (->acceptedFileTypes([...])).
Additional context
Providing a way to customize acceptedFileTypes is consistent with how other properties are handled in Filament actions (e.g., chunkSize, maxRows, csvDelimiter, etc. all have their own setter methods).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
[Feature Request]: Customizable
acceptedFileTypesinImportActionIs your feature request related to a problem? Please describe.
Currently, in
Filament\Actions\ImportAction, theacceptedFileTypesfor theFileUploadcomponent are hardcoded within thesetUp()method:This prevents developers from easily overriding or extending the allowed MIME types for the CSV import. For example, some systems, browsers, or operating systems might identify CSV files with slightly different or obscure MIME types, and developers cannot add them without entirely overriding the
$action->schema([...]), which is very cumbersome as it requires duplicating the internal CSV parsing logic present in the originalsetUp()method.Describe the solution you'd like
It would be extremely helpful to introduce a property and setter/getter methods for
acceptedFileTypeswithin theImportActionclass so it can be customized fluently.Example implementation:
Then, in the
setUp()method, simply call it dynamically:This allows developers to do:
Describe alternatives you've considered
schema(): We can call->schema([...])on theImportAction, but this involves copying a massive chunk of logic handling the CSV chunking and parsing directly into the resource file, which defeats the purpose of having a pre-built action.ImportAction: We can create a customCustomImportAction extends ImportActionand overridesetUp(). However, this again requires copying the entire setup block just to change one line of code (->acceptedFileTypes([...])).Additional context
Providing a way to customize
acceptedFileTypesis consistent with how other properties are handled in Filament actions (e.g.,chunkSize,maxRows,csvDelimiter, etc. all have their own setter methods).Beta Was this translation helpful? Give feedback.
All reactions