7

I'm building a custom content type. I've set a bunch of site columns I add to the content type. The content type is used in a custom list definition within a ContentTypeRef node.

I'm also willing to remove the OOB title column, but I can't find the correct declaration.

Here is my CT definition :

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Item (0x01) -->
  <ContentType ID="0x01006ffb64509c2341d2bff13b98859f792b"
               Name="MyCT"
               Description="My content type"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
                Name="Title"
                Hidden="TRUE"
                Required="FALSE"
                Sealed="TRUE"
                DisplayName="_hidden"
                ShowInDisplayForm="FALSE"
                ShowInEditForm="FALSE"
                ShowInFileDlg="FALSE"
                ShowInListSettings="FALSE"
                ShowInNewForm="FALSE" />
      <FieldRef ID="{82ea62ec-a683-4685-827e-c9775c42bc15}"
                Name="Other field"
                Required="TRUE"/>
    </FieldRefs>
  </ContentType>
</Elements>

I've also tried by using <RemoveFieldRef/> but the Title column is still visible on newform.aspx, and mandatory.

In my custom list definition, I bound the content type using :

<ContentTypes>
  <ContentTypeRef ID="0x01006ffb64509c2341d2bff13b98859f792b">
    <Folder TargetName="MyCT" />
  </ContentTypeRef>
</ContentTypes>

I'd appreciate a bit of help.

1 Answer 1

11

It's always difficult to properly hide / remove the title field, anyway if it's a content type inheriting from Item (which I bet it is based on its ID inheriting from 0x01) you can safely do the following : Set inherits to FALSE, and rely on the RemoveFieldRef to remove the title field. You won't need to re-enter its definition within the Fields node. Here is a sample of a working XML schema, consuming a content type that will remove the title field and having your custom field "otherfield" added instead.

<ContentTypes>
  <ContentType ID="0x01006ffb64509c2341d2bff13b98859f792b"Name="MyCT" Description="My Content Type" Inherits="FALSE" Version="0">
    <FieldRefs>
      <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
      <FieldRef ID="{82ea62ec-a683-4685-827e-c9775c42bc15}"  Name="Otherfield" Required="TRUE">
      </FieldRef>
    </FieldRefs>
  </ContentType>
</ContentTypes>
<Fields>
      <Field ID="{82ea62ec-a683-4685-827e-c9775c42bc15}" Name="Otherfield" DisplayName="Other field" Description="Other Field" Type="Text" Required="TRUE">
</Fields>
9
  • This is a list schema xml file, isn't it ? In my case, I have a separate content type definition, and a list schema with a <contenttyperef> node to reference the CT. I tried what you suggested in the CT definition. The CT itself looks OK, but the CT in the list has no fields. Do you have any suggestion to keep propagating the CT fields to the list internal CT? I fear this broke this system.
    – Steve B
    Commented Jun 12, 2012 at 10:54
  • Yes, this is a list schema, sorry for being unclear on it. I do have the same as you have, a content type declared separately with the inherits set to false and the remove field ref and a list schema consuming that content type but as you know, you need to duplicate most of the content type / fields definition within the list schema. Commented Jun 12, 2012 at 10:58
  • thanks to VS 2012 RC, the duplication is handled by the custom designer. Using the combination of the RemoveFieldRef element, and the duplication of the content type and field in the list, the Title column is not present anymore.
    – Steve B
    Commented Jun 12, 2012 at 12:12
  • Glad I was able to help :) Thanks for your feedback. Commented Jun 12, 2012 at 12:22
  • Waow, this finally helped me out. Thanks a lot! :3 Commented Nov 8, 2012 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.