List Definitions don't need their own forms…

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:

as-created-by-solution-generator

These are then deployed into your list:

when-deployed-as-seen-in-sharepoint-designer

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.

Advertisements
List Definitions don't need their own forms…

3 thoughts on “List Definitions don't need their own forms…

  1. 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!

    Like

  2. 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

    Like

  3. 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).

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s