November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Got the followig answer from EPiServer Developer Support today:
"I just had a discussion with the core developers on this. According to them we don't support it and are actually actively denying editing nested blocks in OPE."
So that pretty much answeres it. It's intended behaviour as it is not supported.
Hi,
I don't think it's impossible. As in web-form we support nested property in EPiServer:Property control using "dot notation", I believe MVC could also work. The problem here could be your view model. Have you tried a "flattened" view model instead of nesting ImageModel in TeaserModel. For example:
class TeaserModel
{
public string Heading { get; set; }
public Url ImageUrl { get; set; }
public string AlternativeText { get; set; }
}
Then:
var editHints = ViewData.GetEditHints<TeaserModel, TeaserBlock>();
editHints.AddConnection(m => m.AlternateText, b => b.Image.AlternateText);
editHints.AddConnection(m => m.Url, b => b.Image.Url);
Does anyone know if it is possible to use ViewData.GetEditHints<TViewModel, TContentData> to connect properties on a ViewModel to properties on a nested block? For example, if we have a simple block called Teaser, defined as follows:
This block contains a block called Image, defined as follows:
The TeaserBlockController creates a ViewModel from the TeaserBlock to pass to the View, defined as follows:
To connect properties on the ViewModel to the ContentData, we need to use the method ViewData.GetEditHints<TViewModel, TContentData>. This works fine, as long as we're not using it on a nested block. This works fine for properties defined directly in TeaserBlock, however, it does not work on properties in nested block. E.g.
When rendering the properties in the ViewModel using the HtmlHelper PropertyFor extension method, the Header property becoms editable (as expected since it is automatiacally mapped due to the equal name and type on the ViewModel And Block). However, it seems impossible to get properties on the nested block Image editable.
Does anyone know if this is the intended behaviour, if this is a bug, or if there is any other way to achieve the desired result of being able to get DOPE editing on the properties on the nested block?
Thank you for advice on this!