Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using the default siteEditField function

@Html.SiteEditField(Model.Component, Model.Component.Fields["Heading"])

And the field does not exist in the broker it generates an exception, that the field does not exist. What I expected was that the method

public static MvcHtmlString SiteEditField(this HtmlHelper helper, IComponent component, IField field, int index)

Would validate the input of value, if the field is empty or none existing to generate the siteedit tags for empty field.

How can this best be achieved; Extending the SiteEditHelper is not allowed since its a sealed class.

share|improve this question
which version of DD4T are you using? – Bart Koopman Sep 4 '14 at 15:29

You could create your own SiteEdit Extension methods helper which wrap the DD4T one e.g.

 public static class MySiteEditHelpers
      public static MvcHtmlString SafeSiteEditField(this HtmlHelper helper, IComponent component, IField field)
           if(field != null)
              return helper.SiteEditField(...)
           return new MvcHtmlString(string.Empty);

(Alternatively || Additionally) you could raise this as an issue on the DD4T GitHub, fork the repo, fix it, and submit a pull request for the next release!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.