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

Mandatory properties

Vote:
 

When we decorate a property as [Required], we are forced to enter this value upon creating this page (before we even get into the page). The screen that comes up is really ugly and non user-friendly. Is there any other way to make required properties behave like in CMS 6 - when you would get a error first when you tried to publish the page?

#71761
May 28, 2013 14:30
Vote:
 

We would like to know this as well.

In general, we think the approach to show a modal dialog is wrong. Mostly because if i'm a content-editor, and i need to fill in a required XHtmlString property, there is no way to see that property in perspective with the rest of the page. So as a content editor, it would be very hard to see the full picture, and you probably end up filling the XHtmlString with dummy data.

#71762
May 28, 2013 14:40
Vote:
 

I agree that using [Required] is not very user friendly. Especially when used on blocks used as page properties and as stand-alone. It’s not always that easy for editors to see the big picture, like Martijn mentioned

Two solutions right off the bat:

1: Add a validator class that implements IValidate<YourContentType> and the Validate method. If you return a list of validation errors with at least one item, save will fail and display your error message. It’s easy to localize messages this way as well, so that’s a nice bonus. if your validation passes you simply return Enumerable.Empty<ValidationError>() from the validate method.

2: Add a custom validation attribute and decorate your content model property with that one.

#71791
Edited, May 29, 2013 11:13
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.