November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
Using custom complex objects as properties on a page model cant be done by default. Depending on what you want to achieve with the list I would suggest either creating a custom property definition or setting up a selectionfactory.
Episerver CMS properties have to be able to load from/save to primitive types (datetime, int, decimal, etc.). In cases of complex types, you need to define a backing type to let the system knows how to save that property to a LongString one, and how to read from it (it does not have to be LongString, of course, but that is the most common backing type). I think the links provided by Gustav are good starting point.
Hi Gabe,
What you want to do should be possible with a PropertyList<T>
although using a ContentArea and blocks is typically recommended.
What you're missing is the PropertyDefinitionTypePlugIn
, have a look at the documentation: https://world.episerver.com/documentation/developer-guides/CMS/Content/Properties/generic-propertylist/.
Hey all,
Thanks for all of the help it's much appreciated.
I realize that I'm working in an Episerver 7 environment and the feature that Jake Jones is referring to is only avaible in Episerver version 9+. I will work with my team on updating our CMS version then attempt to implement the `PropertList<T>` method.
Best,
Gabe
I have a complex JSON object with nested lists and nesteded values. Traditionally in a MVC environment I can use List Model binding which allows me to map to a list nested within the object. Below is an example of how it would be done in traditional MVC within a single Model file.
public class StudentRush : PageData
{
public virtual ContentArea Form { get; set; }
public virtual ContentArea FormSubmit { get; set; }
public virtual List<ElectronicAddress> ElectronicAddresses { get; set; }
}
public class ElectronicAddress
{
public virtual string Address { get; set; }
public virtual object Id{ get; set; }
public virtual bool IsFromAffiliation { get; set; }
}
When I try this in Episerver I get the error Type...could not be mapped to a PropertyDefinitionType. This is the case even when I use IList. Does anyone know how I can achieve model binding without straying too much away from the traditional method?
Thanks