1

I have created a few custom field validators in Sitecore and I'm running into an issue when testing them in the experience editor. For each error, I only see one banner at a time showing a failed validation. Here is an example:

enter image description here

In this example, you can see that I have two errors. The first is for a link on the page not being set, and the second is for the alt text field on a link being empty. On this page, I have three links that are not set and three links that are set but do not have alt text, so I would expect there to be a total of six errors displayed as banners. What appears to happen is that the first instance of each validation error is the only one posted and linked to via the Show error hyperlink. When I resolve one of the validation failures and save, again, the banner is displayed. However, it now links to the next error identified on the page. Is there an easy way to show one banner for each validation failure, even if they are of the same type? I'm trying to prevent content authors from having to save each time they want to figure out where the next validation error has occurred. Thanks for the help!

1 Answer 1

1

I think I figured it out! Sitecore is merging messages with the same text, so making the message unique to the validation failure fixes the error. Originally I was setting the error message text as follows in the parameters section of the validator item:

enter image description here

Instead of doing this, I am now setting the message within the custom validator itself as follows:

this.Text = this.GetText("Alternate text is missing in the link field \"{0}\". ID: \"{1}\"", field.Item.Name, field.Item.ID.ToString());

Here is what the result looks like:

enter image description here

Hope this helps someone else out!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.