Community

Custom rules header name

Hello again!!!

Is there a way to customize the rule error header and not only the message? I am having an issue where 3 fields call to the same rule validation, and if any of them return a rule error, the flag header contains the name of the 3 fields. See my attached image.

Regards

Was this article helpful?

0 out of 0 found this helpful

Comments

4 comments

  • Avatar
    Permanently deleted user
    Hello,

    By default, if your rules are not succeeded errors are raised in all fields that are referenced in this rule.
    You can specify which fields should have errors(C#):
    Context.Field("Field").HasRuleError=true;
    or
    Context.Field("Field").HasRuleError=false;

    regards
    Timur





    0
  • Avatar
    Permanently deleted user
    Hi Sr!

    Yes, I see that behavior by default. So, the header will always display the field names that are referenced to the rule except those whose HasRuleError flag is set to false. But there is no way to customize the header, lets say that instead of displaying the field names I would like a more generic header, like if I had a validation for all the fields in the form, and even when all the fields have a rule error I would like a short description header, instead of: Field1,Field2,Field3,Field4,Field5,Field6,Field7....

    Regards
    0
  • Avatar
    Permanently deleted user
    Hello,

    In order to provide a descriptions for rule erros, consider using error messages:

    Context.ErrorMessage="Your message";

    If your rule errors refers to many fields and you dont all of them to be displayed when error is raised, you can use a foreach statement to assign HasRuleError equal to false(C#):

    foreach(IField f in Context.Fields)
    {
    f.HasRuleError=false;
    }

    After this statement assign fields in which this error should be raised, at least one field must be specified.


    Regards
    Timur

    0
  • Avatar
    Permanently deleted user
    Hello Timur

    Yes, I already use the ErrorMessage property to assign a custom message. It was just the header what is causing issues but I might implement your solution.

    Thanks man!
    0

Please sign in to leave a comment.