We're experiencing the 'No model set' error message in the markup where we are calling the Glass Editable
method. This is present after adding the rendering via the Experience Editor
and choosing to 'Create New Content' for the datasource
.
No model set
at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression
1 field, Expression
1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer) in ~\Glass.Mapper.Sc\GlassHtml.cs:line 565
I'm assuming it's because after selecting to create the new Item the rendering is reloaded but before the Item has finished being created hence the Model not being set.
The code isn't particularly fancy
View
@if (Html.Glass().IsInEditingMode || !string.IsNullOrEmpty(Model.HeadingTitle))
{
<h3>@Html.Glass().Editable(Model, x => x.HeadingTitle)</h3>
}
<div class="sitecore-content">
@Html.Glass().Editable(Model, x => x.Information, x => Html.Sitecore().Field(I_BaseInformationConstants.InformationFieldName).ToString())
</div>
Controller
public ActionResult TextBlock()
{
// GetLayoutItem method from GlassController
var basicContent = GetLayoutItem<ITextBlock>();
return View("/Views/Shared/Components/TextBlocks/TextBlock.cshtml", basicContent);
}
I can wrap the code in a Null
check to prevent the error but then the Editable
aren't present to enter content. Anyone address this problem before?
x => Html.Sitecore().Field(I_BaseInformationConstants.InformationFieldName).ToString()
as a third parameter? And can you post the Controller Action code?