Silverstripe Version:
4.1.0 Question:
I’ve implemented a custom DataObject for Behance Projects which I would like to import on the ModelAdmin instance I’ve created.
What I thought would be the best solution is to include a button along side the export / print / import buttons.
My questions is what would be the best way to do this or if it’s even possible?
Hi @ekersten, it sounds like you want to create an import button, but as you noted yourself, an import button already exists. Can you describe in more detail what you want your new button to do?
@JonoM what I would like to do is make a request to the Behance API and import the projects.
I currently have a DataObject setup to host some of the API data and some extra fields. So the request would match based on the Behance ID and update or create my DataObjects accordingly.
I don’t have much experience with this so hopefully someone else will chime in, but if you want to work on multiple records at once I would take a look at the GridFieldImportButton code and try making a new button based on that. If you want to work on individual records instead BetterButtons was a great solution in 3.x for adding a button to the Edit form but I don’t know of an equivalent technique in 4 yet. You could add a custom action to each row in the GridField though by following these instructions.
You could also consider setting up a queued job to run as frequently as you like that checks for new or outdated records and adds any missing information from the API as necessary, saving you some manual effort.