Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
Hi Moontear, please add it as answer then and mark as answer (unless the accepted answer is better?) –  Anders Rask Sep 26 '11 at 10:32
    
@AndersRask Errm pardon me? Add "it" as answer? What is "it"? I already have an accepted answer for this question as you can see. –  Dennis G Sep 26 '11 at 12:25
    
In your edit you specified what solved your problem. If this differs from the accepted answer, you should create a new answer and set that as accepted answer. the reason for this is so that when others with similar problems find your question, they will look for accepted answer, so this sould match with what really was the issue... If you think stefan's answer is an acceptable solution you can also keep that as accepted answer. –  Anders Rask Sep 26 '11 at 18:58
    
Thanks for your help Anders Rask. Stefan's answer is fine though. Different solutions for problems exist ;-) –  Dennis G Sep 26 '11 at 21:01
add comment

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks Stefan. So what problem am I generating when I remove the content type from my schema.xml? Without the content-type everything works fine and when looking at the content types of the list I have content type of "my list name" in there. This content type does not appear under Site content types. –  Dennis G Jan 13 '11 at 10:32
    
Even if you remove all Content Types from the schema.xml there will be a Content Type "behind the scene" (at least System). I can't see an upcoming problem if you do so but I didn't proof this case because Content Types are the most important feature in SharePoint and people working without CTs are later in an uncomfortable situation (Search, Refinements, Content Deployment, Content Deployment Rules, etc.) –  Stefan Weyer Jan 19 '11 at 13:33
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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