CollectionEditorDescriptor returning 404

Vote:
 

Hi, I've tried to create a custom from element wth a list of objects using CollectionEditorDescriptor with the code I have below:

public class PredefinedColorpickerBlock : TextboxElementBlock
    {
        public class ColorCollection
        {
            [ClientEditor(ClientEditingClass = "foundation/editors/ColorPicker")]
            [Display(Name = "Hex Value", GroupName = SystemTabNames.Content, Order = 10)]
            public virtual string HexValue { get; set; }
        }

        [Display(
            Name = "Color Hex Values",
            Description = "Color hex value",
            GroupName = SystemTabNames.Content,
            Order = 10)]
        [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<ColorCollection>))]
        public virtual IList<ColorCollection> ColorHexValues { get; set; }

        [PropertyDefinitionTypePlugIn]
        public class ColorListProperty : PropertyList<ColorCollection>
        {
            protected override ColorCollection ParseItem(string value) => JsonConvert.DeserializeObject<ColorCollection>(value);
        }
    }

but when trying to edit the form element, the console returns an error 404 (screenshot below)

Is there something I'm missing?

I've tried searching around and found that the URL that dojo is trying to get has a + sign /episerver/shell/Stores/metadata/Foundation.Features.Forms.Elements.PredefinedColorpickerBlock+ColorCollection?dojo.preventCache=1631153602140 and thought that was the one causing the issue, so I've tried adding allowDoubleEscaping="true" into the web.config (not quite sure on this might be the solution as well cause this might cause security issues in the future) and somehow got the form element working.

but now, the form doesn't get submitted and sends me this error: 

can anyone guide me on this one? or has anyone gotten into this issue as well and found a solution? 

Update: I somehow resolved the submit issue but still wondering if there are any workaround on the CollectionEditorDescriptor issue.

Update 2: Somehow forgot about this issue and found the culprit. I've mistakenly placed the ColorCollection class inside the PredefinedColorpickerBlock. 🤪

#261979
Edited, Sep 09, 2021 2:40
Vote:
 

I also have the same case.

#263404
Sep 20, 2021 12:20
Vote:
 

Hi @Nickolson,

For me, I've resolved the issue because the CollorCollection was inside the PredefinedColorPickerBlock.

The updated code right now (which now works) is this:

namespace Foundation.Features.Forms.Elements
{
    [ContentType(DisplayName = "Predefined Colorpicker",
        GUID = "13bfd1d2-c51d-4da0-b6b0-d1634177f8eb",
        GroupName = "Configuration Question Elements")]
    public class PredefinedColorpickerBlock : InputElementBlockBase
    {
        [Display(
            Name = "Color Hex Values",
            Description = "Color hex value",
            GroupName = SystemTabNames.Content,
            Order = 10)]
        [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<ColorCollection>))]
        public virtual IList<ColorCollection> ColorHexValues { get; set; }

        [PropertyDefinitionTypePlugIn]
        public class ColorListProperty : PropertyList<ColorCollection>
        {
            protected override ColorCollection ParseItem(string value) => JsonConvert.DeserializeObject<ColorCollection>(value);
        }
    }
    public class ColorCollection
    {
        [ClientEditor(ClientEditingClass = "foundation/editors/ColorPicker")]
        [Display(Name = "Hex Value", GroupName = SystemTabNames.Content, Order = 10)]
        public virtual string HexValue { get; set; }
    }
}
#263409
Sep 20, 2021 12:30
* 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.