Glass.Mapper icon indicating copy to clipboard operation
Glass.Mapper copied to clipboard

Glass BeginEditFrame

Open qkhaipham opened this issue 8 years ago • 9 comments

So I'm a big fan of GlassMapper and also a real big fan of quickly creating edit frames for sitecore by using the Glass.BeginEditFrame function. Unfortunately this does not always seem to work, ( a lot of the times the dialog that opens does not contain the fields I specified. ) Is this a known issue? Or can I work around it?

qkhaipham avatar Nov 02 '16 14:11 qkhaipham

This isn't a known issue, can you provide more information and we can investigate.

On 2 November 2016 at 14:32, qkhaipham [email protected] wrote:

So I'm a big fan of GlassMapper and also a real big fan of quickly creating edit frames for sitecore by using the Glass.BeginEditFrame function. Unfortunately this does not always seem to work, ( a lot of the times the dialog that opens does not contain the fields I specified. ) Is this a known issue? Or can I work around it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mikeedwards83/Glass.Mapper/issues/251, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHj0A0t4GGZ_GjxdYVkM7jSUa0cThukks5q6J8ZgaJpZM4KnTjp .

mikeedwards83 avatar Nov 02 '16 15:11 mikeedwards83

Hi Mike,

I just noticed a pattern or behavior, not sure if this is as designed or not, but it appears the name of the property in the model must match the name of the sitecore field, for the Glass.BeginEditFrame function to work? ( Even though there's an attribute mapping with the field id on the model though. )

Our sitecore field is called "Datasource" on a specific template, in my model I had a property called "Item" which was mapped with the field "Datasource", with attribute mapping on FieldId. The glass begineditframe started to work when I renamed "Item" to "Datasource", so I would guess the editframe magic doesn't work with the attribute mapping?

qkhaipham avatar Nov 02 '16 15:11 qkhaipham

I recently did a test and didn't find a problem with Attributes or IDs.

mikeedwards83 avatar Dec 18 '16 09:12 mikeedwards83

Hi Mike, thanks for looking into it, I still sometimes encounter this problem, and it kinda happens randomly but I'm able to work around it with the method above. I'll let you know if I can find out more when this happens again.

qkhaipham avatar Dec 19 '16 09:12 qkhaipham

We've also run into this issue. It appears related to the order of the fields, and I think it's related to being placed before/after when the field's owner template changes.

I'll try to get a simple repro available.

richardszalay avatar Jan 24 '17 01:01 richardszalay

@richardszalay Any update on this?

mikeedwards83 avatar Feb 21 '17 19:02 mikeedwards83

Not yet unfortunately. I'll try to get some time to look at it over the next few weeks.

richardszalay avatar Feb 21 '17 19:02 richardszalay

I have a similar issue with BeginEditFrame when I use interfaces as Glassmapper models. I get a "null reference exception" with the following code:

@using (Html.Glass().BeginEditFrame(Model, "Edit title", x => x.Title)) { ... }

Model is an interface. If I instead implement a concreate class using the interface and map item to this instead, things works as intended.

I don't know if the following stacktrace helps:

at Sitecore.Web.UI.WebControl.GetItem() at Sitecore.Web.UI.WebControls.EditFrame.InitializeFromPipeline() at Sitecore.Web.UI.WebControls.EditFrame.ExpandParameters() at Sitecore.Web.UI.WebControls.EditFrame.RenderFirstPart(HtmlTextWriter output) at Glass.Mapper.Sc.GlassHtml.EditFrame(String title, String buttons, String path, TextWriter output) in c:\TeamCity\buildAgent\work\8567e2ba106d3992\Source\Glass.Mapper.Sc\GlassHtml.cs:line 171

madsriise avatar Apr 27 '17 14:04 madsriise

The problem is in the line with the following code:

path = infoConfiguration.PropertyGetter((object)model) as string;

When using "interface" as model "path" is blank. When using a concrete class implementing the interface "path" is resolved correctly.

"Path" is mapped like this:

[SitecoreInfo(SitecoreInfoType.Path)] string Path { get; }

madsriise avatar Apr 28 '17 10:04 madsriise