We are using DXA for implementation of our website. There is strange behavior when XPM is applied. This is scenario

  • Schema has mandatory and non-mandatory fields, lets take just text fields as examples.
  • Rendering is OK in the case of mandatory field or non-mandatory field which has some text and source of the page is like enter image description here
  • If the field is non-mandatory and without value, output is different and looks like this enter image description here

As it can be noticed there is no XPM comment which will give the information about which field should be editable with XPM. - Code in View used to render non-mandatory fields is enter image description here

WebRequestContext.IsPreview is always true for our current development environment so that part is ok. Model.TipText is null in that case, and maybe this is causing the issue.

Problem is related to the output because there is XPM related comment in the source of the page, so XPM does not recognize there is field without value which should be allowed for editing. Without this comment there is no placeholder "<< add text >>" when XPM is active.

Also it is tried with different approach and placing first div as it is on the following image, but same issue is there enter image description here

So, how we can fix this issue? Why there is no XPM related comment which is necessary mark some field as editable through XPM?

1 Answer 1


WebRequestContext.IsPreview will allways be true on your Staging site, it's probabaly not the best name of a parameter, but the idea was that on the future we could perhaps properly detect if we were in an XPM view or not.

The problem with empty fields is that they don't exist in the published json (since that is build from the Components XML, in which there are no empty elements for fields that don't have a value). This means the model property will remain null and thus doesn't have the information avaiable which is needed for the XPM markup.

I guess we missed something here, since it indeed does make sense to have XPM markup for empty fields too, in case the view renders it like:

<div @Html.DxaPropertyMarkup(() => Model.Headline)
    @if (Model.Headline != null)

But that will require a lot of additional processing on the model mapping, since then we need to consider all the fields of the Schema. You can log this as an issue on https://github.com/sdl/dxa-web-application-dotnet/issues and I'll make sure we look at it for the next release (of if you figuere out the solution yourself, you are free to submit a pull request on our development branch of course).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.