Friday, December 21, 2012

RichTextField require RichImageField

Usually when you create page layouts you always have image fields on your page. Recently I created a page with just one RichTextField. The problem was that the RichTextField did not render properly. It rendered just as an ordinary FieldValue in a ms-formfieldvaluecontainer. After some extensive trial and error I found out that RichTextField required at least one RichImageField somewhere in the page layout to work properly. Apparently the RichImageField adds stuff that also is needed for RichTextField. So my solution was just to add a RichImageField for the PublishingRollupImage field, which is a field inherited from the Page content type that you never use anyway, in an empty div with display none and the RichTextField was working just fine.

<div style="display:none">
    <PublishingWebControls:RichImageField
        id="ImageFieldSharePointBugFix"
        FieldName="PublishingRollupImage"
        runat="server"/>
</div>

Yet another day in SharePoint paradise...