Glass.Mapper
Glass.Mapper copied to clipboard
RenderingParametersModelFactory -> Fails to set fields, falls back to standard values
The logic that sets the field value isn't working as expected

It does get a field by the logic of the FieldCollection:

But those fields aren't set on the fake item, so the SitecoreService falls back to the standard values.
If you load the fields first by calling: fakeItem.Fields.ReadAll(); then the load works as expected.
Edit:
I was getting different results when querying it from mvc or web api, so i did some extra testing.. it appears that the lazy.onlyreferenced was causing the issue and not the load logic of the fields. Can the load logic be made configurable? So we can take control over the lazy loading? (like the other methods on the IMvcContext) Or is there a good reason to hide it?
Hi
Can you give me an example of the webapi code you were using?
Thanks
I've removed the code from the webapi, since it was just for testing purposes.. it basically was the implementation of the RenderingsParametersModelFactory createModel method in a web api method with fixed guids to load a specific renderingparameter template.
the template had a droptree field configured which wasn't loaded properly with lazyloading.onlyReferenced, switching it to disabled worked for me.
What is odd is why the WebAPI had problems vs a standard rendering.
If I have time this evening i'll setup the test case, so you can see what I did.. Don't think there is a problem with using it in web api or mvc.. the issue here is that we don't have control over the lazy load option. It's the only method that doesn't expose the option. To override it I had to create/register a custom implementation of IGlassHtml so I could set a custom RenderingParametersModelFactory which had the lazy option disabled.