Hi. I’m new to Grav and making my first plugin. I’m trying create a ‘run once’ type of function from it’s admin page to pull data from another websevice into a yaml. I can’t figure out how to make my function run only when a button or toggle is selected, and then the admin page saved. My attempts:
-
I can’t figure out if I can add a custom submit button on the plugin’s admin page and catch that– I can’t see other plugins do this, so I guess not.
-
Using
onAdminSave(Event $event){…I can get the value of a toggle (set in blueprints.yaml) and run my update event. But I can’t figure out how to modify the toggle’s event value… ie before its saved - ie put it back to the default value. Is this possible? -
Using
onAdminAfterSave(Event $event){…I can’t figure out how to modify the saved toggle value. I’ve tried$this->grav['config']->set('plugins.shortcode-mbg.do_updated', '0);with no success
Are these approaches workable or is there a better approach?
thanks!