I have a registration form. I have added custom workflow to the form. Custom workflow checks if user input is valid. If not valid, I would like to display a validation message e.g "Invalid input. Contact admin".
Here is sample code:
try
{
if(ExistsInDatabase)
{
//do something
}
else
{
//show validation message "Input does not exist in DB
}
}
catch (Exception)
{
return WorkflowExecutionStatus.Failed;
}
return WorkflowExecutionStatus.Completed;
How do I achieve this? Thanks.
NB: I don't think I can implement validation on the form itself in the backoffice because the validation involves checking the DB using EF Core.
Thanks Marc! Yes, I am able to do the custom validation. I just wasn't sure what to do when the validation fails. Thank you for pointing me in the right direction and for pointing out that custom workflows are generally for actions after successful submission and validation.
I am going to implement the validation first then. Thank you.
Umbraco Forms: in-code (custom) validation
Hi,
I have a registration form. I have added custom workflow to the form. Custom workflow checks if user input is valid. If not valid, I would like to display a validation message e.g "Invalid input. Contact admin".
Here is sample code:
How do I achieve this? Thanks.
NB: I don't think I can implement validation on the form itself in the backoffice because the validation involves checking the DB using EF Core.
Hi dev-thandabantu
Would you be able to handle the serverside validation notification to do your check when the form is submitted?
https://our.umbraco.com/documentation/Add-ons/UmbracoForms/Developer/Extending/Adding-an-Event-Handler#adding-a-server-side-notification-handlers-to-umbraco-forms
Workflow steps are generally for custom actions after the form is successful submitted and validation is complete...
Regards
Marc
Thanks Marc! Yes, I am able to do the custom validation. I just wasn't sure what to do when the validation fails. Thank you for pointing me in the right direction and for pointing out that custom workflows are generally for actions after successful submission and validation.
I am going to implement the validation first then. Thank you.
is working on a reply...