Try our conversational search powered by Generative AI!

Hiding Boolean property

Vote:
 

While Joels exampel: http://joelabrahamsson.com/hiding-episervers-standard-category-property/
Works like a charm for categoryList, I cannot get it to work wih the type bool. 

Also reading, http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/7/Editing/How-To/Registering-a-Custom-Editor/

The code below is a mixup from Joels example and episerver sdk, but I cannot get it to work, is there something I have missed?

using System;

using System.Collections.Generic;

using EPiServer.Shell.ObjectEditing;

using EPiServer.Shell.ObjectEditing.EditorDescriptors;

using EPiServer.Templates.Alloy.Models.Pages;

 

namespace EPiServer.Templates.Alloy.Business.EditorDescriptors

{

    publicclassHideProperties

    {

        ///<summary>

        /// Editor descriptor that will create a checkbox to be able to edit boolean values.

        ///</summary>

        [EditorDescriptorRegistration(TargetType = typeof(bool))]

        publicclassBooleanEditorDescriptor : EditorDescriptor

        {

            public override void ModifyMetadata(

          ExtendedMetadata metadata,

          IEnumerable<Attribute> attributes)

            {

                base.ModifyMetadata(metadata, attributes);

 

                dynamic mayQuack = metadata;

                var ownerContent = mayQuack.OwnerContent;

                if (ownerContent is StandardPage)

                {

                    metadata.ShowForEdit = false;

                }

            }

        }

    }

}

#70533
Apr 22, 2013 21:13
Vote:
 

It should be bool? :)

#70589
Apr 23, 2013 15:51
Vote:
 

@Duong Nguyen: What do you mean?

#70592
Apr 23, 2013 16:35
Vote:
 

Sorry, made you confused. The value type in Boolean properties are Nullable<bool>. So you have to register your editor descriptor to the type bool? instead of bool.

#70593
Apr 23, 2013 16:38
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.