SharePoint field not showing in Display/Edit/New pages

Daniel Revell picture Daniel Revell · Dec 1, 2009 · Viewed 11.7k times · Source

I've written a schema for a list that only needs to add one column to the default custom list which is a number field called months. The field is shown on the default view and is indeed created on the list. The list is autopopulated with values which get set properly. The problem is that the field doesn't appear on the display/edit/new pages. It can be set through the datasheet view. I don't understand why it isn't showing up when I specifically set it to in the schema.

Would very much appriciate any suggestions.

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" 
      Title="ReviewPeriods" 
      FolderCreation="FALSE" 
      Direction="$Resources:Direction;" 
      Url="Lists/ReviewPeriods" 
      EnableContentTypes="TRUE" 
      BaseType="0">
 <MetaData>
  <ContentTypes>
   <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
  </ContentTypes>
  <Fields>
   <Field ID="{B99EB797-4057-4a75-90BF-B40D0F89A9D9}"
             Type="Number"
             Decimals="0"
             Min="0"
             Max="100"
             Percentage="FALSE"
             Name="Months" 
             Required="TRUE"
             Group="SEED"
             DisplayName="Months"
             StaticName="Months"
             ShowInDisplayForm="TRUE"
             ShowInEditForm="TRUE"
             ShowInNewForm="TRUE">
   </Field>
  </Fields>
  <Views>   
   <View BaseViewID="0" 
            Type="HTML"
            WebPartZoneID="Main" 
            DisplayName="Default View" 
            DefaultView="TRUE" 
            SetupPath="pages\viewpage.aspx" 
            ImageUrl="/_layouts/images/generic.png" 
            Url="AllItems.aspx">

... Hidden Stuff ...

<ViewFields>
          <FieldRef Name="LinkTitle"></FieldRef>
          <FieldRef Name="Months"></FieldRef>
    </ViewFields>
    <Query>
     <OrderBy>
      <FieldRef Name="Title">
      </FieldRef>
     </OrderBy>
    </Query>
   </View>
  </Views>
  <Forms>
   <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
   <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  </Forms>
 </MetaData>
</List>

Answer

Per Jakobsen picture Per Jakobsen · Dec 1, 2009

The problem is that you add the field to the list, but at the same time enable content types and specify that the only content type to use is Item (0x01) which doesn't include the field. So you're adding/editing Items and then you don't get the field.

There are two solutions:

  1. Don't enable content types (and then also remove the whole <ContentTypes> section)
  2. Create a new content type including the field and add that content type instead of Item