silverstripe / silverstripe-userforms

UserForms module provides a visual form builder for the Silverstripe CMS. No coding required to build forms such as contact pages.
BSD 3-Clause "New" or "Revised" License
134 stars 226 forks source link

Allow form actions to customized and added to the form as per form fields #68

Open helenclarko opened 11 years ago

helenclarko commented 11 years ago

Currently we can only add a new page on complete, what if we had the choice to link to a website or download link.

wilr commented 10 years ago

Assigned to the 2.0 release as I would expect this to be a nontrivial API and would need a considered approach (rather than hardcoding the options). Functionality wise, I want to see the post form actions be represented as separate classes (EditableFormAction) which could be applied to the form as per the fields. Those actions can then be encapsulated, extended and customised in ways exactly.

wilr commented 9 years ago

See the advanced workflow module for the concept of actions that can be added to the form.

clodeindustrie commented 6 years ago

Hey, Any extra pointer on this? I'm thinking about taking that on. Letting the user create a list of actions finishing with a terminal action that returns any type of response.

NightJar commented 6 years ago

Since Actions are essentially fields, and with 4.0 the action on a form is no longer bound to the controller it's factory funciton resides on, I would look at making EditableFormAction type editable form fields, and perhaps presenting them in a different manner.

This way you can leave each type (e.g. Email) as it's own class, with the functions applicable to it residing in it's edit form.

Wilr's original comment about this being non-trivial would remain true though, as it would require one to move all the existing functionality of "Recipients" etc. to an encapsulated EditableFormAction. This could also have UI and potential performance issues.

This would leave the core UserForm submission handler to only worry about storing submissions, and not handle actions associated with it - or this could also be an action type if one were to e.g. chain actions. But that's getting a bit advanced.

It is important to design the interface to be easily extensible, as I can easily imagine this becoming a well used feature, and developers should be able to easily add actions of their own, much in the way one can currently create EditableFormFields.

This is quite a major piece of work, and will need some serious design consideration before jumping into it, particularly if you're aiming for the stretch of chainable actions (aka action list, or pipeline). Good luck!

clodeindustrie commented 6 years ago

Cool thanks for that, I might create two new type of things EditableFormAction objects to handle how the response is returned to the page (Full reload, html fragment, json etc...) and something else to handle side effects (emailing, updating third party service like Hubspot etc..) that could be pipelined.

Juanitou commented 6 years ago

That could be so nice for something as simple as modal forms, where the response would update the modal with the ReceivedFormSubmission text. As far as I understand it, this is not possible now since the process() function always redirect to the 'finished' page.