Different sets of [Required] properties depending on content status (Draft, Published) etc

Vote:
 

Hey,

I got a question from a customer today which got me thinking. The use case is that they want to quickly create pages, i.e have very few required properties.

They are fine with the pages being sort of empty while in Draft. But when they go ahead and Publish the content, there are more properties that must have values.

How would I go about this? There's the OnPublishing-event where one could check values on said properties, or one could extend the Required-attribute and make it take a Status-flag, or...

Pros/cons? stupid idea altogether?

#183284
Edited, Oct 10, 2017 14:57
Vote:
 

Take a look at implementing a validator based on IContentSaveValidate interface. 

http://world.episerver.com/documentation/Class-library/?documentId=cms/10/41AB842A

Then you will get in a context that contains the SaveAction meaning you can have different validation based om which SaveAction it is (e.g Publish) 

#183297
Oct 10, 2017 19:57
Vote:
 

Thanks!   Looks like a nice approach.

#183299
Oct 10, 2017 20:21
Vote:
 

Hey Thomas

I blogged about that very same idea: https://www.david-tec.com/2017/07/hiding-required-properties-on-the-create-new-page-in-episerver/

David

#183304
Oct 10, 2017 22:02
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.