In two separate instances on my current project, I've tried using "Min Items" on my nested content property editor, and that causes the property editor to return null even when it it's populated. When I set "Min Items" to 0 it doesn't return null. I'm running v7.12.3
Here's my null check in case how I'm checking for null is incorrect for nested content.
If you have both min and max items set to be 1, then it identifies the implementation as a SingleNestedContentProperty, and instead of returning an IEnumerable
Soooo, when you have them both set to 1, you'd access the value like so:
Cannot bind source type
Umbraco.Web.PublishedContentModels.NcBusinessUnitHeader to model type
System.Collections.Generic.IEnumerable`1[[Umbraco.Core.Models.IPublishedContent,
Umbraco.Core, Version=1.0.6837.12334, Culture=neutral,
PublicKeyToken=null]]. The source is a ModelsBuilder type, but the
view model is not. The application is in an unstable state and should
be restarted.
Essentially you are sending to your partial 'ncBusinessUnitHeader' an object of type NcBusinessUnitHeader (which will implement IPublishedContent) but I suspect the Model or Inherits statement at the top of your 'ncBusinessUnitHeader' partial view, is expecting an IEnumerable
So if you change that statement at the top of the 'ncBusinessUnitHeaer' partial view to be IPublishedContent instead of IEnumerable
Maybe a bug report
In two separate instances on my current project, I've tried using "Min Items" on my nested content property editor, and that causes the property editor to return null even when it it's populated. When I set "Min Items" to 0 it doesn't return null. I'm running v7.12.3
Here's my null check in case how I'm checking for null is incorrect for nested content.
Hi bh
When you use min items - are you setting it to 1? and are you also setting maxItems to 1?
Looking at the Property Value Converter for Nested Content:
https://github.com/umbraco/Umbraco-CMS/blob/1bb593d264a085f94a3ce3bd710392b350561430/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentPublishedPropertyTypeExtensions.cs#L20
If you have both min and max items set to be 1, then it identifies the implementation as a SingleNestedContentProperty, and instead of returning an IEnumerable
Soooo, when you have them both set to 1, you'd access the value like so:
regards
Marc
Here's the error message I get using this snippet..
Hi Bh
This is now a different issue...
Essentially you are sending to your partial 'ncBusinessUnitHeader' an object of type NcBusinessUnitHeader (which will implement IPublishedContent) but I suspect the Model or Inherits statement at the top of your 'ncBusinessUnitHeader' partial view, is expecting an IEnumerable
So if you change that statement at the top of the 'ncBusinessUnitHeaer' partial view to be IPublishedContent instead of IEnumerable
that should get you past that error!
regards
Marc
is working on a reply...