November Happy Hour will be moved to Thursday December 5th.

UI not showing error message when creating a block from a content area

Vote:
 

I'm having problems with the validation error messages not showing when they should. I've created a custom validation class for a block type that inherits from IValidate, and while the validation is working fine the error message isn't always shown. If I create a new block from the assets pane the error message is shown as it should, but if I click the "create a new block" link in a content area it's not displayed. Is this a bug or have I missed something?

#142152
Dec 02, 2015 18:11
Vote:
 

I'm having the exact same issue. It kind of renders validation pointless if the end users have no idea what they're doing wrong

#143134
Edited, Jan 13, 2016 13:31
Vote:
 

Episerver has confirmed that this is a bug, this is the answer I got from their support:

A bus is reported for this issue.
CMS-2385:UI not showing error message when creating a block from a content area
The bug will be made public after initial triage meeting. You can then follow it up throughhttp://world.episerver.com/support/Bug-list/
Thanks for reporting this issue. 

#143135
Jan 13, 2016 13:36
Vote:
 

I emailed Episerver to ask when this would be fixed, and this time they told me the bug had been closed as "won't fix" as it will work if you also set the property name. So there is a way to fix it which is great, hopefully they'll update the documentation as well so more people won't get stuck on this.

#144911
Feb 22, 2016 15:55
Vote:
 

annelie

How do you mean if you also set the property name? Could you reply with an example? Really appreciate the update though!

#144912
Feb 22, 2016 15:57
Vote:
 

No problem! When you create the validation error, set the property name as well and the error will show up. Here's an example:

public class TestValidation : IValidate<MyBlock> {

public IEnumerable<ValidationError> Validate(MyBlock instance) {

return new List<ValidationError> { new ValidationError { ErrorMessage = "There is an error", PropertyName = "MyBlockError" } };

}

}



#144913
Edited, Feb 22, 2016 16:01
Vote:
 

Ah okay, I didn't know you could do that (to be fair I never looked). That'll work perfectly, although perhaps a bit of a shame if your error concerns multiple properties?

Actually, there's a RelatedProperties property where you can specify a string array for that case.

#144914
Edited, Feb 22, 2016 16:03
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.