2

I really have spent hours on this, to no avail. Time to call in the cavalry.

The are many examples how to trap onSubmit for a formio form when it is configured as a component in Angular. But I can't find any example of trapping the onSubmit for a formio form configured as a module.

Why is it important? After submission of new or edited record on a formio form, the URL defaults to a view of that record .../<form>/<recid>/view. I want to redirect to a different URL. That's easy when the form is defined an as Angular component:

export class AssessmentFormComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

  onSubmit(submission: any) {
    window.location.href = 'about:blank';
    alert('Thank you for completing the assessment');
  }
}

I tried similar code in a module, the code within the onSubmit is never triggered. Obviously there is a way to do this; I just can't find it. Please advise.

1 Answers1

0

You can add HTML for formio like this

<formio #Form [form]="form" [submission]="formSubmission"
    (change) = "onChange($event)" [options]="formIoOptions"
    (submit) = "onSubmit($event)" (render)="onFormLoad(Form)">
</formio>

in .ts write your onSubmit method.

Vinay
  • 2,272
  • 4
  • 19
  • 34
  • Thanks for the answer Vinjay. It's unclear to me where this HTML should reside. When you have time, please expand on the answer. Thanks. – Alan Collins Jul 13 '20 at 20:16
  • 1
    This HTML will be inside the component where you want to write the logic of your form. – Vinay Jul 14 '20 at 04:34