Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidateSettings field gets wrong setting if empty/no PreValue is chosen #627

Closed
inetzo opened this issue Aug 18, 2021 · 1 comment
Closed

Comments

@inetzo
Copy link

inetzo commented Aug 18, 2021

When you add more than one fields with PreValues, the ValidateSettings methode gets the wrong setting value.
Hard to explain so here are some screenshots:

afbeelding

afbeelding

The message appears, i choos "Emailaddress". Then i add an other field of the same type and call this "Lastname" and again choose no value for ProfileField.

afbeelding

afbeelding

Reproduction

Here is an example class of the formfield:

    public class TestField : FieldType
    {
        [Setting("ProfileField", Description = "", View = "Dropdownlist", PreValues = "Name, Emailaddress, Phone")]
        public string ProfileField { get; set; }

        public TestField(IScopeProvider scopeProvider)
        {
            Id = new Guid("6e73befe-c39e-436f-ac45-240ed645889e");
            Name = "Testfield";
            Description = "Test";
            DataType = FieldDataType.String;
            FieldTypeViewName = "FieldType.Test.cshtml";
            Icon = "icon-user ";
            HideLabel = false;
            SupportsPreValues = false;
            SupportsRegex = false;
            SortOrder = 25;
        }

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

            if (string.IsNullOrEmpty(this.ProfileField))
                exceptions.Add(new Exception("Choose a value"));
            return exceptions;

        }

    }

Expected result

I would expect that the setting value of ProfileField == null when no PreValue is chosen.

Actual result

The prevalue of the first set field is passed

@AndyButland
Copy link

Thanks - I've been able to replicate, and have found a fix, so will include in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants