Custom form control validation

Tom Troughton asked on July 21, 2015 15:11

I've developed a custom form control according to the documentation. As advised I provided an overridden IsValid method.

My assumption was that this method would only be called if the form control was used for a required field. However, it seems to fire even for optional fields. Is this expected behaviour? If so, do I need to check within IsValid whether the field is required? If so, how do I do that?

Correct Answer

Virgil Carroll answered on July 21, 2015 16:03

If you look at the Fields View in form, page type or custom table, even if a field is not required you can set different validation criteria to check against...so yes every field is going to get checked through the IsValid event. You could just let the base IsValid method run instead of overriding it (or before overriding it) and that would pick up the error for a required field. you should really only override it if you want to only do your own validation or extend the validation to do something the out of the box can't (such as compare a combination of fields together)

0 votesVote for this answer Unmark Correct answer

Recent Answers


Tom Troughton answered on July 22, 2015 13:00

Thanks for the reply Virgil. Makes sense.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.