Validator not firing

My forms tend to be more complex in nature and not straight Template Forms. I have one in particular where it is a tab with multiple models, basically one model per tab. I have requiredValidators on different fields throughout the tabs and I have a Save and Submit button. I want the Save button to just save the various models as is so a user can come back at a later time and complete the form. The Submit button should fire the validators to ensure that all required fields are included before submission. So I made the Save button just a normal button and the Submit button I made a submit button. However when I hit submit, the validators fail to fire.

So can I handle this so that one submit button fires all the validators? Is this possible? Can I have separate template forms on each tab, but just one submit button? Is there a way to trigger the individual validators in code?

Hi @kgordon,

A submit button will fire validators only if it is in the same TemplateForm as the validators. You cannot validate multiple forms with a single button (you would also need to handle their Submit event which is not possible). Another thing to keep in mind is that validators which are not in the current tab will not fire as they are not initialized yet and thus invisible to the user.

Thanks, I thought as much, will have to workaround this.

I had a similar problem. My workaround was to insert labels below the controls instead of validators and to trigger their visibility by the OnChange events of the respective controls.
Works also really well with forms that trigger an action/call a controller.

1 Like

@Meister_Eder Thanks for the tip, I think I'll have to incorporate this into my solution.