I am writing a plugin to handle a sequential form, that is after pressing the Submit button, the user is redirected to the next page in a sequence, which in turn may contain form data.
Everything works as planned, except I now want a mechanism to cancel the sequence by using a ‘reset’ button.
FYI, the draft plugin is at https://github.com/finanalyst/grav-plugin-sequential-form . Once I get the reset button working, I will offer to republish it.
I cannot yet work out how to detect which button of a form was pressed (submit or reset). That is, in onFormProcessed
, how can I detect the button that was pressed?
The aim would be to redirect to the first page in the sequence, stop form propagation, and reset the form data.
I am thinking that it will be necessary to add javascript to the form so that hitting reset sends a redirect to the first page.
I have studied form.php, anithubd the templates, and I can see button.task, but there is no documentation about what button.task does.
Also, I can see that blueprints are important. I was wondering whether I could use a rule to cancel data. However, there is no information about blueprints.