List definitions don’t need their own forms – if you’re happy with the out of box ones. Mostly, if you use something like the solution generator to create your List definition, it will create a number of forms by default for you:
These are then deployed into your list:
However, you don’t actually need these in your definition, unless you’re providing your own custom forms! Otherwise you can use the following code to use the standard SharePoint new/edit/view forms:
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" />
</Forms>
That’ll keep the codebase smaller. What’s actually happening here is that we’re using the standard ‘form.aspx’ page from the pages folder in 12 Hive (not in a site!) This has the standard ListFormWebPart on it already, so it’s ready to display your list items as normal!
You can also do the same with your Views in your Schema (so we can eliminate the files for them too). The Views are actually added to the pages as ListViewWebParts, and typically they use the ‘ViewPage.aspx’.
<View DefaultView="TRUE" Type="HTML" DisplayName="All Items" SetupPath="pagesviewpage.aspx" Url="AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">
Again, you can provide custom forms for these lists – but actually I reckon that a lot of the time you wouldn’t want to.
That’s awesome! I hadn’t thought to do that. I will definately roll this into the next release of SPSource so that it doesn’t create these files unless necessary. Will have to do some homework into how you know whether it’s doing custom forms. Must create a custom url for them…I wonder if it’ll just ghost the files into the list for you…if so I can teest for that!
Yup, I reckon that checking to see if the page is customized (unghosted) or not would be the way to determine that.
I’ve got no idea how you determine if the file is unghosted, though.
Ah, just had a thought. What if someone installs a List Definition feature which uses it’s own custom forms, and then runs the SPSource/Solution Generator against them? The file might still be ghosted, but it’s not the ‘standard’ one.
Tricky
Yep – the XML for the standard forms is described on the “Understanding Schema.xml” page by Microsoft.
The real puzzle is why site definition WSP files don’t have the forms described as per their own documentation in their own list definition schema.xml files… (discovered this afternoon).