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

Set Category as required with EditorDescript

Vote:
 

Hi!

I tried to implement an EditorDescriptor to make Category a required property. But i can't get it to work. I have other required properties which isn't inherited from PageData that uses the RequiredAttribute and those works. 

What happens is that when i create a new page which should have category as required property it looks as it should be required

But i can proceed without entering a value. My other propert works fine.

The EditorDescriptor looks like this:

    [EditorDescriptorRegistration(TargetType = typeof(CategoryList))]
    public class CategoryListEditorDescriptor : EditorDescriptor
    {
        public override void ModifyMetadata(
           ExtendedMetadata metadata,
           IEnumerable attributes)
        {
            base.ModifyMetadata(metadata, attributes);
            if (metadata.PropertyName == "icategorizable_category" && metadata.FindOwnerContent() is IEventPage)
            {
                metadata.IsRequired = true;
                
            }
        }
    }

Isn't this the way to do it? 

I can get it to work when overriding category in my implemented page type and applying the RequiredAttribute

[Required]
public override CategoryList Category { get; set; }
#146529
Mar 17, 2016 10:51
Vote:
 

I noticed that if I remove my EditorDescriptor and only using the override of Category it doesn't work either. It only works when I'm using both the override and the EditorDescriptor together.

#146532
Edited, Mar 17, 2016 10:59
* 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.