Partilhar via


Field Element (Field Types)

Applies to: SharePoint Foundation 2010

Represents a characteristic of the field type.

<Field
  Name="Text">
</Field>

Attributes

Attribute

Description

Name

Required Text. A string that represents the name of the specific aspect of the field type that the Field element represents. The value must be one of the strings listed in the table below.

Child Elements

None

Parent Elements

FieldType Element (Field Types)

Remarks

Field element children of FieldType elements are configured in fldtypes*.xml files in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\XML.

Each FieldType element has several required and optional Field elements distinguished by their Name attribute. The following table describes these elements. In the object model, a field type is represented by the SPFieldTypeDefinition class. The latter class has a read-only property corresponding to all but two of the rows of the table. (The exceptions are InternalType and SQLType.) Except where noted otherwise, the property names match the value of the corresponding Name attribute.

Value of Field Element's Name Attribute

Description

AllowBaseTypeRendering

Optional Boolean. The default is FALSE. Specifies whether a client application renders the field as its base type (also called the ParentType), if the client application cannot determine how to properly render the custom field type. If set to TRUE, and the client application cannot properly render the custom field type, the client application renders the field as the default SharePoint Foundation parent field type from which it inherits.

CAMLRendering

Optional Boolean. The default is FALSE. Specifies whether the field is rendered on list views using the CAML markup in a RenderPattern element elsewhere within the parent FieldType element. The default FALSE means that the field is rendered on list views by an XSL transform in a fldtypes*.xsl file, which is the standard system for field rendering on list views. (However, this element has no effect on field rendering on Display, New, and Edit forms. A RenderPattern would still be the standard way of rendering the field on a Display form.)

FieldTypeClass

Optional String, but required for all your custom field types. Represents the strong name of the field type class library. "FieldTypeClass" includes the class name and assembly name with Version, Culture, and PublicKeyToken, for example, <Field Name="FieldTypeClass">CustomFieldTypes.RegularExpression.RegularExpressionField, CustomFieldTypes.RegularExpression, Version=1.0.0.0, Culture=neutral, PublicKeyToken=57e55365ec0ce80a</Field> (Only the fully qualified class name is included for field types built into SharePoint Foundation.)

FieldEditorUserControl

Optional String. Represents the relative path to a field_typeFieldEditor.ascx file that defines a control that appears, in SharePoint Foundation, in the Additional Column Settings section on the New Site Column page. The control enables column creators to set, for a particular column, the variable properties of the field type. E.g. "/_controltemplates/RegularExpressionFieldEditor.ascx". If there is no <Field Name="FieldEditorUserControl"> element, then the special properties of the field type are rendered by the PropertySchema Element (Field Types) element.

FieldEditorUserControl should be a fixed, nonlocalizable string.

Filterable

Required Boolean. Represents whether a list with a column that is based on this field type can be filtered according to the value of the column that uses this type. If set to TRUE, the header of the column is a control that users can use to filter the list.

InternalType

Optional String. Represents an internal base type. Do not use a <Field Name="InternalType">element in your custom field type definitions.

ParentType

Required String (but can be an empty string). Represents the name of the type from which the field class is derived. The possible values are exactly the same as the possible values for the Type attribute of the Field Element (List) element. If the field type is not derived from another type, then the value is an empty string:

<Field Name="ParentType"></Field>. It must never be empty in your custom field types. All custom types inherit from another type.

In the SharePoint Foundation object model ParentType is called BaseRenderingTypeName.

ShowOnListAuthoringPages

Optional Boolean. The default is TRUE. Represents whether this field type is displayed for inclusion on lists. If set to TRUE, SharePoint Foundation displays this field type on list authoring pages so that users can include the field type on their lists.

In the SharePoint Foundation object model ShowOnListAuthoringPages is called ShowOnListCreate.

ShowOnDocumentLibraryAuthoringPages

Optional Boolean. The default is TRUE. Represents whether this field type is displayed for inclusion in document libraries. If set to TRUE, SharePoint Foundation displays this field type on document library authoring pages so that users can include the field type in their document libraries.

In the SharePoint Foundation object model ShowOnDocumentLibraryAuthoringPages is called ShowOnDocumentLibraryCreate.

ShowOnSurveyAuthoringPages

Optional Boolean. The default is TRUE. Represents whether this field type is displayed for inclusion on surveys. If set to TRUE, SharePoint Foundation displays this field type on survey authoring pages so that users can include the field type in their surveys.

In the SharePoint Foundation object model ShowOnSurveyAuthoringPages is called ShowOnSurveyCreate.

ShowOnColumnTemplateAuthoringPages

Optional Boolean. The default is TRUE. Represents whether this field type should be displayed as a column template field type. If set to TRUE, SharePoint Foundation displays this field type on column template authoring pages so that users can select to create a column template of this field type.

In the SharePoint Foundation object model ShowOnColumnTemplateAuthoringPages is called ShowOnColumnTemplateCreate.

SQLType

Optional String. Represents the SQL data type that will be used to store the data in the content database. Do not use a <Field Name="SQLType">element in your custom field type definitions.

Sortable

Required Boolean. Represents whether a list with a column that is based on this field type can be sorted on the column that uses this type. If set to TRUE, the header of the column is a control that users can use to sort the list.

TypeDisplayName

Required String. Represents the display name of the field type in the user interface (UI). In SharePoint Foundation, it appears in the Type column on the Customize [list] page (listedit.aspx). It is also used in place of "TypeShortDescription" if the latter is not present.

"TypeDisplayName" should be a localizable string.

TypeName

Required String. Represents the name of the field type. This must be unique among all field type names on the SharePoint server farm.

"TypeName" should be a fixed, nonlocalizable string.

TypeShortDescription

Optional String. Represents the short description of the field type that is displayed in the UI. In SharePoint Foundation it appears with a radio button in the Name and Type section of the New Site Column and Create Column pages and in the Type column of the Site Column Gallery. If there is no <Field Name="TypeShortDescription"> element, then "TypeDisplayName" is used.

"TypeShortDescription" should be a localizable string.

UserCreatable

Optional Boolean. The default is TRUE which enables users to add fields of this field type to lists. Setting the value to FALSE allows use of the field type in list schemas, but hides the field type from users on the Name and Type section of the New Site Column and Create Column pages.

Example

The following example defines a custom field type.

Important

The RenderPattern is obsolete. It is shown here solely to assist in the debugging of custom fields that were originally developed against earlier versions of SharePoint Foundation.

  <FieldType>
    <Field Name="TypeName">SocialSecurityNumber</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">Social Security Number</Field>
    <Field Name="TypeShortDescription">Social Security Number (123456789, 123-45-6789)</Field>
    <Field Name="AllowBaseTypeRendering">TRUE</Field>
    <Field Name="FieldTypeClass">
      AdventureWorks.FieldTypes.SPFieldSSN, AdventureWorks.FieldTypes.SPFieldSSN,
      Version=1.0.0.0,Culture=neutral,PublicKeyToken=90734cc53324b79c
    </Field>
    <RenderPattern Name="DisplayPattern">
        <Column HTMLEncode="TRUE" /> 
        <Column HTMLEncode="TRUE" UseRelatedField="TRUE"/> 
    </RenderPattern>
  </FieldType>

See Also

Tasks

Walkthrough: Creating a Custom Field Type

Concepts

Custom Field Types

How to: Create a Custom Field Class

Custom Field Type Property Rendering

How to: Create a Custom Field Type Definition