F
Filament6mo ago
Hugo

Dynamic columns on Importer class

Hello, I am trying to create dynamic columns on my importer classes. I tried using importer options and passing in a client, because clients may have different columns than others. Some columns are always the same for every client but some have other types of columns. My goal was to pass in the client through the options and then loop through the extra columns of the specific client and create the ImportColumns in a dynamic way. What i found out was that I can't access $options in the getColumns method. is there a way to do this?
6 Replies
Dan Harrin
Dan Harrin6mo ago
You could try using a lifecycle hook on the importer class like beforeSave where you can access the options etc
Hugo
HugoOP6mo ago
Will it help me create the dynamic ImportColumns and show them on the modal that pops up upon importing a file?
Dan Harrin
Dan Harrin6mo ago
Hmm, no, sorry you'll probably need a custom ->form() on the action
Hugo
HugoOP6mo ago
ok, thank you. I'll do my best to make it work somehow.
pechtelt
pechtelt6mo ago
Hi Hugo, did you make this work? I had the same question, found out that you can make use of getOptionsFormComponents() on your importer class. See: https://discord.com/channels/883083792112300104/1233021779102924852
Hugo
HugoOP6mo ago
Sorry for the very delayed answer. I ended up making my own classes, adapting some of filament's in order to access the options array wherever I want.
Want results from more Discord servers?
Add your server