SaaS CMS has officially launched! Learn more now.

AllowedTypes got an error when drag and drop in Form Editing

Vote:
 

Hi, 

I've tried this with standard Alloy installation and there is weird thing. Simply edit the PageListBlock, and put AllowedTypes (typeof(ArticlePage)) to the property "Root" which is PageReference. 

When I go to Form Editing, try to drag and drop my Article page to the property, I got an error: 

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'EPiServer.Core.PageReference' because the type requires a JSON string value to deserialize correctly. To fix this error either change the JSON to a JSON string value or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path 'isPreferredLanguageAvailable', line 1, position 32. 

The page picker is still working as expected with restriction of content type. I know there is a known bug with drag and drop in Edit view. But what about Form editing? Does anyone know why and how to fix it?

Thanks,

/Dung Le

#80032
Jan 14, 2014 5:27
Vote:
 

Don't worry! I think this's also a bug. ;)

But we can easy to live with as below:

[PageListBlock.cs]

        [Display(
            GroupName = SystemTabNames.Content,
            Order = 5)]
        [Required]
        [UIHint("PageReferenceExtended")]
        public virtual PageReference Root { get; set; }

    

Create new editor descriptor: (e.g: PageReferenceEditorDescriptorEx.cs)

    [EditorDescriptorRegistration(TargetType = typeof(PageReference), EditorDescriptorBehavior = EditorDescriptorBehavior.ExtendBase, UIHint = "PageReferenceExtended")]
    public class PageReferenceEditorDescriptorEx : EditorDescriptor
    {
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);
            AllowedTypes = new Type[] { typeof(ArticlePage) };
            EditorConfiguration["dndSourcePropertyName"] = "contentLink";
        }
    }

    

That all!

// Ha Bui

#80085
Jan 14, 2014 18:28
Vote:
 

It's work. Thank so much!

#80110
Jan 15, 2014 9:47
Vote:
 

This is still a problem in latest version. Tried AllowedTypes on a property of type ContentReference to make sure only one type of page could be used. Same error. Any idea if this will be solved in future releases of episerver?

#85107
Apr 15, 2014 13:58
Vote:
 

Did you try lightly change "PageReference" to "ContentReference" ?

The key in my previous posting is:

EditorConfiguration["dndSourcePropertyName"] = "contentLink";

    

I've been reported this bug and will update bug's link here later.

This actually my mistake, I missed it and don't report it's ealier. So sorry!

//HaBui

#85119
Edited, Apr 15, 2014 16:45
Vote:
 

Ok, so when the bug is fixed we don't need to use your extra UIHint, only AllowedTypes?

#85223
Apr 17, 2014 9:24
Vote:
 

Yes, I think so.

//Ha Bui

 

#85224
Apr 17, 2014 9:31
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.