plomino / Plomino

Powerful and flexible web-based application builder
33 stars 37 forks source link

can't create a form which downloads content on submission #770

Closed djay closed 7 years ago

djay commented 8 years ago

User problem

Lets say you want a form with a button "download as XML" which takes the input and downloads as XML.

There isn't a good way to do this

Options downloads

Submission action

Actions are the most intuitive place to put code to handle submissions. We could have "submission action" with a formula that takes a temporarydocument as the context and gives full control over the the response.

A user can then add a action with a download macro to perform downloads.

Currently however Action formulas are never called on submission. They are called at render to give a link to redirect to. So it would change what they do (although conceptionally if they can't be made to act on submission they should be called links not actions IMO).

change beforeCreate

move beforeCreate outside of the template. but how to signal that you don't want to render the template? at the moment any string is interpreted as an error.

[x] New event

onDisplay or onRender or beforeFormDisplay or beforeLoad?

Something that gets called before the template is rendered and has the ability to determine if what will happen next i.e. redirect or stream or render as normal.

How should a formula indicate what should happen next?

Options for temp docs

form.getTemporaryDocument

ie an api that any formula can turn the request into a validated temporary document.

tempdoc in every formula.

Like plominoContext, there is plominoRequestDocument in every formula which provides an consistent way to access the data thats been submitted

djay commented 8 years ago

I think both submission action and a new event are good solutions to this.

What do you think @ebrehault ?

djay commented 7 years ago

we have ondisplay event now which solves this