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

Required Page Type Property from Inherited Page Data

Vote:
 

Does anyone know how best to override on a Page Data Property.

 

I want to add a [Required] around a Category page property to enforce it is set when adding a page.

e.g.

“Article Page” Inherits “Standard Page” which inherits “Site Page Data” which Inherits “Page Data”

 

I want to set Category to “Required” within “Article Page”.

public virtual CategoryList Category

    

When I use this within Article Page

[Required]

public override CategoryList Category { get; set; }

    

It enforces the required when creating a new page but show two Category options in Form editing.

 

 

#66684
Mar 06, 2013 18:29
Vote:
 

[Required]

public virtual CategoryList Category {get; set;} seems to do the trick.

#66689
Mar 06, 2013 21:57
Vote:
 

The virtual creates it as anouther property the override allows it to edit the "Page Data" property but two show in form edit mode either way I try. I need it to override and then only display once in form edit?

#66719
Mar 07, 2013 15:07
Vote:
 

I thought I only got one property maybe I did miss the second one.

#66720
Mar 07, 2013 15:45
Vote:
 

This seems to be working and making only one visable in edit mode and force's required when saving, it does not show required before adding a page so works as I need it.

[Required]
[Editable(false)]
public override CategoryList Category { get; set; }

#66723
Mar 07, 2013 18:33
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.