umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

Settingsattribute IsMandatory doesn't work in workflows #1172

Open SofusMunch opened 4 months ago

SofusMunch commented 4 months ago

As indicated in the title, the IsMandatory property on the SettingsAttribute doesn't validate/prevent submit when used in custom workflows.

Version 13.0.2

AndyButland commented 4 months ago

This is true. We added this fairly recently based on your request here: https://github.com/umbraco/Umbraco.Forms.Issues/issues/1108

But it's only making amends client-side to add the necessary ng-required attribute.

Looking at the out of the box workflows, we also have validation server side to prevent submission - e.g. in the "Slack V2" workflow we have:

        public override List<Exception> ValidateSettings()
        {
            var exceptions = new List<Exception>();

            if (string.IsNullOrEmpty(WebhookUrl))
            {
                exceptions.Add(new Exception("'Webhook URL' setting has not been set"));
            }

            return exceptions;
        }

If exceptions are returned, that'll bubble up to the client-side and prevent submission.

I'll keep this open as arguably it would be better to not have to do this, and the IsMandatory setting should be enough. But as it stands you should add this server-side validation check for your required fields.