WebHare community

Submit a WebHare form prematurely

Is there a way to submit a multi-step WebHare form through a custom button from an earlier page than the last?

I’m trying to implement a “Save” functionality where I have a custom submit button that submits the form, so I’m adding a <button type="submit"> button like the normal one. However, it seems a form submit only works if I’m on the last page of it, so I can’t submit from earlier pages than the last.

Or at the very least, can I get the accompanying RPCFormBase class so I can call JS functions like gotoPage?

Hmm I’m now seeing that the custom submit button triggers a wh:form-response event with a valid event.detail.result.resultsguid, so I guess it tries to submit it. It also adds a form result.

However, the form doesn’t jump to the ‘thank you’ page, it just keeps showing the form like nothing happened.

      this._navigateToThankYou(result.result && result.result.richvalues);
      this.onSubmitSuccess(result.result);

onSubmitSuccess sets resultguid, and is called after navigateToThankYou. you’ll have to debug why it doesn’t work.

Well, _navigateToThankYou calls let nextpage = this._getDestinationPage(state, +1);.

From the first page, the value of nextpage is 1. So in the next bit:

if (nextpage != -1 && state.pages[nextpage] && state.pages[nextpage].dataset.whFormPagerole == 'thankyou')

state.pages[nextpage] isn’t the ‘thankyou’ page but a normal page, so the if isn’t TRUE.

I guess _navigateToThankYou shouldn’t look at the next page, but at the last page? Which probably will break other stuff :slight_smile: