I would like it to be possible to to have a part in a page. And on a POST-request to that page, handle the POST in a
post-function exported from the part, and render something to the page (where the part is included, same as with GET).
Currently nothing is rendered where the part was when we do a POST-request to a page. (See example below)
I basically want to get the same benefits of having parts and pages, with using a form.
I want to do validation serverside in my part, and render out the form again, with the inputfields’ errors indicated.
GET Request renders:
POST Request when pressing the “Send name”-button renders:
We can see that no part is rendered on a POST to a page, and the
post function in the part is not called.
We had a discussion around what is possible and not regarding this topic, as well as some workarounds in this thread on the #developer channel on Slack.
Alternative ways to solve this in XP today feels a bit like hacks:
- Just do everything in a page - The problem is that I want to reuse the part in several pages, and I don’t want to duplicate code.
- Send the POST to a service, and render the resulting html. - This has the same problems as with page above.