Question

I'm using Visual Studio 2010's template "List Definition" to create a new list definition for a document library.

Nothing fancy at all - I only want to add a couple of fields to the list and to the default view. Adding the fields to <Fields> in schema.xml and the respective <FieldRef> to <Views> is no problem, so I have the list with my custom fields.

I only can't get them to show up in the New/Edit forms. I thought ShowInDisplayForm="TRUE" and ShowInNewForm="TRUE" was the way to go, but it doesn't seem to do anything - then I figured out that the new list definition template adds it's own "Upload.aspx, FileDlg.htm, EditDlg.htm".

I tried putting <ows:ListProperty Select="MyColumn"> in EditDlg.htm. No change. Now I saw that VS2010 puts a lot of code in the schema.xml under <Form Type="NewFormDialog" Path="EditDlg.htm"> which starts with <ListFormOpening>.

My question: How to work with the VS template to add my custom fields to all relevant dialogs (Edit/New/View)?


EDIT: Figured out how to resolve this by removing the <ContentTypes> reference from the Schema.xml as described here. I still don't understand whether this is the right way to do this as I now removed the content type from the library (whereas I can still add documents just fine...). Explanation anyone?

Was it helpful?

Solution

The "problem" is that every list and library is bound to a content type. Unfortunately Microsoft hided that by disabling "Allow Content Type Management" by default. When you create a new field like you did it is added to the list but not bound to the content type the list depends on. If you go to the list settings and enable Content Type management you can add the new "list fields" to the content type and you will see them.

Best approach for adding fields to a list template is to create your own fields and add them to a content type. Then you create the list template based on this content type (easy with VS) or add this content type to the list too.

OTHER TIPS

Removing the ContentTypes reference isn't necessarily the right way but I'm pretty sure it's the wrong way. They're there for a reason.

You have two options. First, you can create a content type and specify the fields that way. See http://msdn.microsoft.com/en-us/library/ff728096.aspx for information on how to build up the custom list through a content type.

Second, you can use the Custom list type and just add your own fields.

  1. After adding a blank list definition to the soluiton through Visual Studio, add in whatever fields you want in the <Fields /> section.

  2. Replace the ContentTypeRef for ID 0x01 (Item) with a new blank one. See this blog post for a sample and full explanation. http://jopx.blogspot.com/2007/05/sharepoint-2007-how-to-create-custom.html

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top