Replies: 1 comment
|
I'm running into the same-ish issue. Some data that goes to a form action is needed for an invalidated server page load. I could set it in cookies, but it'd be really nice if the form action's locals persisted to the next request. I'm assuming remote functions will help solve this issue as the query function can be supplied with any necessary data as opposed to being restricted to data fed in by handle. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Is there a way to tell if a form action is invoked as part of a request from an enhanced form?
In my app I populate
event.localswith a database object called "currentOrg". I have a form action that switches the current org. As per the docs, I'm updatingevent.localsin that form action, however depending on how the form action is being invoked this is not always necessary.Scenario 1: basic (no enhanced form) POST
The order of ops seems to be:
handle()- setsevent.locals.currentOrgbased on cookieevent.locals.currentOrgto the new org + sets the cookie to contain the new orgload()In this scenario, we definitely need the
event.locals.currentOrgto be updated since the page's load function is being called afterward in order to render the page.Scenario 2: enhanced form POST
handle()- setsevent.locals.currentOrgbased on cookiehandle()load()In this scenario, there is no need to set
event.locals.currentOrgin the form action since the request is completed and a brand new request is made to load the page.Which begs the question - is there a way for a form action to know if it's being requested via an enhanced form? If there is, it would save some cycles to not have to look up the new org from the DB just to put it into
event.locals.currentOrgright before the request is completed.All reactions