F
Filament12mo ago
lodeki

Handling static fields in the ImportAction feature.

Hello , i have case where I want to import units for a particular block.The blocks are already in the db , is there a way to make a select in the importaction for blocks field and do something like
->options(Block::pluck('block_name','block_name')
->options(Block::pluck('block_name','block_name')
6 Replies
lodeki
lodekiOP12mo ago
Any insights here?
Tim van Heugten
Tim van Heugten12mo ago
What is the relation between the units and the blocks? Take a look at https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import#using-import-options, replace the checkbox with your select and in the resolveRecord function set the value when instantiating the model.
lodeki
lodekiOP12mo ago
One block can have several units .One to many.
Tim van Heugten
Tim van Heugten12mo ago
Well, the answer still stands. Let me know if you need help.
lodeki
lodekiOP12mo ago
Got something of the sort above ...Though it feels weird having that outside the columns yet it's one of the columns.
Tim van Heugten
Tim van Heugten12mo ago
But is it part of the import file? Now I’m confused… Obviously you can also make it one of the import columns but then the user should include it in the import file. As IDs are not very user friendly you can ask for a name and then find the matching ID on the backend (mutating the data).
Want results from more Discord servers?
Add your server