Hi everyone.
I've developed a block plugin that displays some information which is important for our school.
Now I want to add a feature where the user can switch between two different display styles. The choice of the user should be saved on the server so that the next time the user views the block, it will already be displayed correctly.
Ideally, there would be a single plain button (or even better: a "rocker switch" like the one used for switching to edit mode in moodle 4.0) to toggle this preference.
I've looked into the Moodle Form API, but it seems that I would need one field for selecting the preference and then a submit button, which would be too bulky for the block. Since the 'No submit button' option from the Form API apparently gets called every time that the form gets constructed, I can also not use that one.
So how can I add a single button which updates a user preference (which I'll probably save in a database table of the plugin) and then reloads the page?