F
Filament2mo 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 Harrin2mo ago
You could try using a lifecycle hook on the importer class like beforeSave where you can access the options etc
Hugo
Hugo2mo 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 Harrin2mo ago
Hmm, no, sorry you'll probably need a custom ->form() on the action
Hugo
Hugo2mo ago
ok, thank you. I'll do my best to make it work somehow.
pechtelt
pechtelt2mo 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
Hugo2mo 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.