Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollectionProperty in the CompositeProperty #163

Open
usigirci opened this issue Apr 10, 2020 · 2 comments
Open

CollectionProperty in the CompositeProperty #163

usigirci opened this issue Apr 10, 2020 · 2 comments
Assignees
Labels
Milestone

Comments

@usigirci
Copy link

Hello,
When I use CollectionProperty in the Composite Property, Composite Property items does not see!
Attached example; when I click "add" composite items' add button, it is not added to the page.
CollectionProperty-CompositeProperty

@fschultz fschultz self-assigned this Jun 6, 2020
@fschultz fschultz added the bug label Jun 6, 2020
@fschultz
Copy link
Contributor

fschultz commented Jun 6, 2020

I've found the root of this problem. It has to do with the JSON deserialization routine. In order to protect the integrity of the system only know types are allowed when deserializing content. The known types are registered automatically at start-up by the CMS scanning the code for used property types. However this seems to fail when property types are nested, such in your example.

The error log would include something in the line of:

Could not deserialize {"$type":"DemoSite.Models.PropertyTypes.AccordionProperty","Color":{"$type":"KalikoCMS.PropertyType.SelectorProperty`1[[System.Int32, mscorlib]]","Value":1}}: Type specified in JSON 'KalikoCMS.PropertyType.SelectorProperty`1[[System.Int32, mscorlib]]' was not resolved.

..identifying what property failed (in this case SelectorProperty<int>)

I will look into fixing this issue, in the meantime the following workaround can be used to resolve the problem:

Add a new class to your project that inherits and implements the IStartupSequence interface. Set StartupOrder to something larger than 0 (this will tell the system to run this code at startup after everything else in the CMS have been initialized).

In the Startup method register any type that is used only by a composite property, in this case SelectorProperty<int>.

using KalikoCMS.Core;
using KalikoCMS.PropertyType;
using KalikoCMS.Serialization;

namespace DemoSite
{
    public class RegisterTypes : IStartupSequence
    {
        public int StartupOrder => 1;

        public void Startup()
        {
            PropertyTypeBinder.RegisterType(typeof(SelectorProperty<int>));
        }
    }
}

Thanks for reporting this bug! I will update this issue once the code has been fixed.

@fschultz fschultz added this to the Release 1.2.6 milestone Jun 6, 2020
@usigirci
Copy link
Author

usigirci commented Jun 8, 2020

You're right; same error log record "Could not deserialize {...."
And workaround worked, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants