Try our conversational search powered by Generative AI!

Adding block to block container - disappears after adding new block

Vote:
 

I have a block that contains a block.  When I add a new block to this block container, it doesn't show and therefore can't be published.

The first class below is my block container.  Second is the block that the container holds.  Third is the page.  

I've basically copied code that a previous developer used to do something similar.  What am I missing?

Thanks,

Tim

    [ContentType(DisplayName = "SelectableColorsBlocks", GUID = "ca4580f9-3e4d-4e24-8cb8-50a76d4d54c7", Description = "")] 

    public class SelectableColorsBlocks : BlockData 
    { 
        [Display( 
         Name = "Listing Title", 
         Description = "", 
         GroupName = SystemTabNames.Content, 
         Order = 10)] 
        public virtual string ListingTitle { get; set; } 

        [Display( 
          Name = "Selectable Colors Blocks", 
          GroupName = SystemTabNames.Content, 
          Order = 20)] 
        [AllowedTypes(typeof(SelectableColorsBlock))] 
        public virtual ContentArea SelectableColorsBlocksArea { get; set; } 
    } 
 

    [ContentType(DisplayName = "SelectableColorBlock", 
        GUID = "5a3b16a1-444b-47ac-bacc-b979d85c0661", 
        Description = "Block to contain selectable background color")] 
    public class SelectableColorsBlock : BlockData 
    { 
        [Display( 
            Name = "Icon", 
            Description = "Icon", 
            GroupName = SystemTabNames.Content, 
            Order = 15)] 
        public virtual Url Icon { get; set; } 

        [CultureSpecific] 
        [Display( 
            Name = "Title", 
            Description = "Title", 
            GroupName = SystemTabNames.Content, 
            Order = 10)] 
        public virtual string Title { get; set; } 

        [ClientEditor(ClientEditingClass = "dijit/ColorPalette")] 
        [Display( 
            Name = "Background color", 
            Description = "Select background color", 
            GroupName = SystemTabNames.Content, 
            Order = 50)] 
        public virtual string BackgroundColor { get; set; } 

        [ClientEditor(ClientEditingClass = "dijit/ColorPalette")] 
        [Display( 
            Name = "Text color", 
            Description = "Select text color", 
            GroupName = SystemTabNames.Content, 
            Order = 60)] 
        public virtual string TextColor { get; set; } 

        [CultureSpecific] 
        [Display( 
            Name = "Main body", 
            Description = "Main body of block ", 
            GroupName = SystemTabNames.Content, 
            Order = 100)] 
        public virtual XhtmlString MainBody { get; set; } 
    } 

 

    [ContentType(DisplayName = "SelectableColorsPage", GUID = "fbbeee2c-02b2-468d-9eb1-31f616f5943a", Description = "")] 
    public class SelectableColorsPage : SitePageData 
    { 
        [Display( 
            Name = "Page Banner", 
            Description = "Page Banner", 
            GroupName = Global.GroupNames.PageBanner, 
            Order = 40)] 
        public virtual ContentReference PageBanner { get; set; } 

        [Display( 
            Name = "Image", 
            Description = "Content Image", 
            GroupName = SystemTabNames.Content, 
            Order = 20)] 
        public virtual Url ContentImage { get; set; } 

        [Display( 
            Name = "Title", 
            Description = "Title", 
            GroupName = SystemTabNames.Content, 
            Order = 50)] 
        public virtual string Title { get; set; } 

        [CultureSpecific] 
        [Display( 
            Name = "Main body", 
            Description = "The main body will be shown in the main content area of the page, using the XHTML-editor you can insert for example text, images and tables.", 
            GroupName = SystemTabNames.Content, 
            Order = 1)] 
        public virtual XhtmlString MainBody { get; set; } 

        [Display( 
            Name = "Selectable Colors Block", 
            Description = "", 
            GroupName = SystemTabNames.Content, 
            Order = 10)] 
        public virtual SelectableColorsBlocks SelectableColorsBlocks { get; set; } 
    } 
#224722
Jun 24, 2020 19:09
- Jun 24, 2020 19:21
When I do get the Publish button to show, I get a could not save property error or nothing happens.

I also verified that the properties for each Block Type and Page Type are not missing by looking at the respective properties in the Admin tab of CMS.
Vote:
 

Code looks fine to me. Can you try removing the AllowedTypes attribute?

AllowedTypes(typeof(SelectableColorsBlock))

And if it works then try adding back or rename one of the block.

#224745
Edited, Jun 25, 2020 2:16
* 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.