Fortis-Collection / fortis

A framework for creating a strongly typed model based on Sitecore templates and the Sitecore API

Home Page:http://fortis.ws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: TextFieldWrapper.Value return RawValue

mikaelnet opened this issue · comments

Most implementations of the IFieldWrapper.Value returns a typed value, for example BooleanFieldWrapper returns a proper bool, LinkFieldWrapper returns a Guid etc. However, the TextFieldWrapper executes the Render() method resulting in a html encoded string. This is sometimes bad since it doesn't reflect the actual value. Also, if it's accidentally used in a razor view, its output would be double html encoded.

I know this would be a very much breaking change to the existing behavior, but it may be worth considering TextFieldWrapper.Value to return the RawValue instead, making it more consistent with the other field types. The RichTextFieldWrapper.Value could then return a IHtmlString. By doing so, the Value property can be used for working with the actual values and the rendering won't be broken. Besides, normal rendering can use just output the FieldWrapper since it implements IHtmlString that performs a proper Render() call.

Thoughts on that?
// Mikael

Apologies for the (very) late response :), in short I agree! While this could be a breaking change I agree that the TextFieldWrapper isn't doing the same as the other fields with regards to the Value property.

As we are making some breaking changes in v4 of Fortis already - it makes sense to add this change to the list. @jasonbert I'm going to make the change and release the beta - we can always revert if there are any major issues.