Copied to clipboard

Flag this post as spam?

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


  • k 256 posts 654 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 26 posts 188 karma points
    Feb 10, 2020 @ 14:52
    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 6132 posts 23951 karma points MVP 7x admin c-trib
    Feb 12, 2020 @ 18:57
    Alex Skrypnyk
    0

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

    Model.Value<IPublishedElement>("director")
    
  • Mikael Axel Kleinwort 140 posts 484 karma points c-trib
    Feb 13, 2020 @ 10:00
    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 151 posts 1022 karma points MVP c-trib
    Feb 13, 2020 @ 10:11
    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 140 posts 484 karma points c-trib
    Feb 13, 2020 @ 10:48
    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