Opticon Stockholm is on Tuesday September 10th, hope to see you there!
AI OnAI Off
Opticon Stockholm is on Tuesday September 10th, hope to see you there!
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.
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;
}
}
}
}
}