Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • k 254 posts 649 karma points
    Sep 22, 2019 @ 14:35
    k
    0

    Nested content

    Hello,

    I am using nested content on umbraco 8.

    I am using the code on : https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Nested-Content/

    But I am getting the below error: enter image description here

    Can someone please help.

    Thanks,

    Kusum

  • Ryan Helmn 23 posts 153 karma points
    1 week ago
    Ryan Helmn
    0

    Do you have any null checks before the variable? If not, could you try doing:

    if(Model.HasValue("director")){
        enter code here
    }
    
  • Alex Skrypnyk 5505 posts 20674 karma points MVP 3x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    if you have only one item in the nested content you have to use

    Model.Value<IPublishedElement>("director")
    
  • Mikael Axel Kleinwort 35 posts 196 karma points c-trib
    1 week ago
    Mikael Axel Kleinwort
    0

    Hi Alex,

    I am curious, do you know why this is so? Shouldn't it be returning a collection with a single item? Does this means I have to check in code each time, or update the code when the nested content changes?

    I am relatively new to using Nested Content and I would like to understand the issue so I can avoid problems, I would appreciate your insight on this a lot.

    Thank you! Mikael

  • Steve Megson 144 posts 888 karma points c-trib
    1 week ago
    Steve Megson
    0

    It should only return an IPublishedElement if the property is configured to require exactly one item (min and max both set to 1). If the property is configured to allow multiple items then it should return an IEnumerable<IPublishedElement> containing one item.

  • Mikael Axel Kleinwort 35 posts 196 karma points c-trib
    1 week ago
    Mikael Axel Kleinwort
    0

    Hi Steve,

    thank you very much for this clarification!

    Mikael

Please Sign in or register to post replies

Write your reply to:

Draft