Tuesday, May 10, 2011

A fix for Content Type Inherits True with Pages

A few of you may have come across issues with SharePoint 2010 and the handling of Inherits="TRUE". When you inherit from the Page content type, you now get all sorts of unexpected issues. The big issue we had was when we overrode a fieldref in a child content type, (eg changing display name or whether it is required) the field was duplicated in the Pages library.

It's weird, in some respects SharePoint knew they were the same field, in other places it thought they were two different fields. eg. it displays the field twice while editing, but both fields have the same display name/required field.

So to fix the problem, when overriding a field ref in a child content type you need to add ShowInEditForm and ShowInDisplayForm to FALSE (yes in capital letters!)

eg.

<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Title" Required="TRUE" ShowInEditForm="FALSE" ShowInDisplayForm="FALSE"/>
<FieldRef ID="{9da97a8a-1da5-4a77-98d3-4bc10456e700}" Name="Comments" DisplayName="Description" Required="FALSE" ShowInEditForm="FALSE" ShowInDisplayForm="FALSE" />

No comments: