Glass.Mapper
Glass.Mapper copied to clipboard
A/B Test not working with View Rendering that uses sitecore model items and Html.Glass().Editable
Steps to reproduce (Glass Vanilla 5.8.172)
- Create a View Rendering
- Create a sitecore Model Item (/sitecore/layout/Models/)
- Add your GlassMapper Models's Namespace to the sitecore model item
- Assign the model to the view rendering
- Use @Html.Glass().Editable() in your view (Example @Html.Glass().Editable(Model, x => x.Text)
- Create a component Test with your new view rendering
- When you switch from A to B in the experience editor you will get the following error:
Value cannot be null. Parameter name: objectToSwitchTo
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Common.Switcher2.Enter(TValue objectToSwitchTo) at Sitecore.Data.Items.ContextItemSwitcher..ctor(Item item) at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression1 field, Expression`1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer) in D:\a\Glass.Mapper\Glass.Mapper\Source\Glass.Mapper.Sc\GlassHtml.cs:line 571

Your properties are missing the Virtual keyword, can you add this and see if works.
hi
We have identified the issue and we are working on a fix.
Hello,
unfortunately I still have the problem with all languages except the default en
You need to make sure you model also contains properties for Langauge and Version
public virtual Language Language{get;set;}
public virtual int Version{get;set;}
Unfortunately I am still able to repoduce. Could you please try it with any other language then en? This is my model:
public class TextImageIndexView
{
[SitecoreId]
public virtual Guid Id { get; protected set; }
[SitecoreField("1A22E54A-8367-4714-BFA0-720B95148B41")]
public virtual string TextImageText { get; set; }
[SitecoreField("C9680286-A269-431D-82F2-7D1DFEE67EDC")]
public virtual Glass.Mapper.Sc.Fields.Image TextImageImage { get; set; }
[SitecoreInfo(SitecoreInfoType.Language)]
public virtual Language Language { get; set; }
[SitecoreInfo(SitecoreInfoType.Version)]
public virtual int Version { get; set; }
}
Any update on this? I am getting the same error. I tried using virtual for all properties but still the same error.
I am wondering if it is related to this https://github.com/mikeedwards83/Glass.Mapper/issues/442