1

Im using SharePoint 2007. Created a custom field for a SharePoint list, which should not be displayed during Item Add or Edit. I have used SharePoint WSP Builder Project in Visual Studio 2008. Created a custom field type. Is as below:

<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
  <FieldType ShowInEditForm="FALSE" ShowInNewForm="FALSE">
    <Field Name="TypeName">****</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">****</Field>
    <Field Name="TypeShortDescription">****</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="Sortable">TRUE</Field>
    <Field Name="AllowBaseTypeRendering">TRUE</Field>
    <Field Name="Filterable">TRUE</Field>    
    <Field Name="FieldTypeClass">**.**, PDFDisplay, Version=1.0.0.0, Culture=neutral, PublicKeyToken=****</Field>
    <Field Name="FieldEditorUserControl">/_controltemplates/****.ascx</Field>
    <PropertySchema>
    .
    .
    <PropertySchema>
    <RenderPattern Name="DisplayPattern">
    .
    .
    </RenderPattern>
  </FieldType>
</FieldTypes>

Even though the ShowInEditForm and ShowInNewForm is set to FALSE, it is displayed when either adding a new item to the list or when editing an item.

In the Field's Control class's constructor set the two properties to false

field.ShowInNewForm = false;
field.ShowInEditForm = false; 

Still is visible in the edits and item adds..

3 Answers 3

1

in sharepoint 2010 => UserControl => CustomFieldControl

protected override void OnLoad(EventArgs e)
    {
        this.Parent.Parent.Visible = true;
        base.OnLoad(e);
        if (SPContext.Current.FormContext.FormMode == SPControlMode.Edit ||
            SPContext.Current.FormContext.FormMode == SPControlMode.New)
            this.Parent.Parent.Visible = false;
    }
0

In you element file (and all places where you use <Field> element that uses you custom field type) for field definition add ReadOnly="TRUE" and it not be displayed during Item Add or Edit:

<Field ID="Your field GUID" Name="Your field name" DisplayName="Display Name" ReadOnly="TRUE" Type="Your custom field type" Group="Your field group" />
1
  • IN my case i dont use features, just created a field definition in Visual Studio WSP builder project in VS 2008. Edited the field definition to have a ReadOnly="TRUE". <Field Name="ReadOnly">TRUE</Field> But still it shows up.Parent field Type was text, changed it to Note..No luck
    – Shaamil
    Jan 13, 2014 at 6:01
0

ShowInEditForm and ShowInNewForm attributes could be overrided in SharePoint list by ContentType Xml definition in FieldRef element.

If the field is ReadOnly then could be problems with update it value programmatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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