Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Submit Lifecycle Triggers #402

Open
crobinson42 opened this issue Dec 23, 2020 · 1 comment
Open

Feature Request: Submit Lifecycle Triggers #402

crobinson42 opened this issue Dec 23, 2020 · 1 comment

Comments

@crobinson42
Copy link

feature request

I would like to have some event driven behavior in forms that are triggered on lifecycle naming conventions, ie: onBeforeSubmit onAfterSubmit etc..

My use case is processing some async data in a custom field that is a child of the form and after the processing is done in the field it makes a final change to the field's value before the submit fires.

Thoughts?

@Dakkers
Copy link

Dakkers commented Mar 8, 2021

I don't know if this would fix your issue but I was facing something similar where I was submitting a form but waiting for some background event to complete prior to my form submission hitting the API. it looks like this:

  async onSubmit (values) {
    // If the draft is in the middle of saving, let it finish before continuing
    if (this.isSavingDraft) {
      setTimeout(() => this.onSubmit(values), 1000);
      return;
    }

   ...

you could alternatively set do something like

myPromiseThingy = this.backgroundEvent();

...

// (inside onsubmit)
if (myPromiseThingy) {
  await myPromiseThingy;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants