How to add custom content type to a custom list

To add a custom content type to a custom list definition , the simple way to do is to add some entries in the schema.xml of the list.

 - Just add the ContentTypeRef of the contents types you want to use .
 - Add EnableContentTypes="TRUE" in the <List > tag

<List xmlns:ows="Microsoft SharePoint" Title="YOURTITLE" Direction="$Resources:Direction;" Url="Lists/MYCALENDAR" BaseType="0" EnableContentTypes="TRUE" Name="NAMEOFLIST" Id="66179222-6e7b-431b-a573-e076593c81bd" Type="106" xmlns="http://schemas.microsoft.com/sharepoint/">
    <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x010200d1ae5eb6622645518535cffe71d43480">
        <Folder TargetName="EntretienDebutMission"/>
      </ContentTypeRef>
      <ContentTypeRef ID="0x010200f2c756888542479f9b66f82140a2de40">
        <Folder TargetName="Evenement"/>
      </ContentTypeRef>
    </ContentTypes>


Sometimes i don't really know the reason but some of the fields are not shown when trying to create a new item in the list. I solved this problem by copying the field definition in the contents type to the schema.xml of the list. and it works fine.
If some know the reason why some fields are not shown ! just comment

Enregistrer un commentaire