In the schema file we have 2 sections which are responsible for custom forms:
<ContentType>
......................
<XmlDocuments><XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
<Display>/Lists/CustomDisplay.aspx</Display>
</FormUrls>
</XmlDocument>
</XmlDocuments>
<Folder TargetName="Item" />
</ContentType>
</ContentTypes>
<Forms>
<Form Type="DisplayForm" Url="DiscussionView.aspx" WebPartZoneID="LeftBottom" />
<Form Type="EditForm" Url="EditForm.aspx" WebPartZoneID="LeftBottom" />
<Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="LeftBottom" />
<Forms>
It's really worth to notice that section <XmlDocument > has two options: 1. you can set form template id which should be place into the form ex:
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ListForm</Display>
<Edit>ListForm</Edit>
<New>ListForm</New>
</FormTemplates>
</XmlDocument>
</XmlDocuments>
ListForm is out the box form template which you can find it DefaultTemplate.aspx - msdn reference
2. you can set the page which should be displayed for the content type:
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
<Display>/Lists/CustomDisplay.aspx</Display>
</FormUrls>
</XmlDocument>
</XmlDocuments>
As you can see the difference between those options is -usage the different element "FormTempates" for form template Id option and FormUrls - msdn reference
The section <Forms> is responsible for forms for a list, not for a particular content type.
One of the real scenario that I found in my project, developers create a custom form for a list and keep the <FormTemplates> untouched.
To make this approach work you should be aware of how the sharepoint treats these 2 sections in the list. First it looks for form urls and it looks for content type FormTemplate and then it puts the form template from content type to the page which is directed in the Forms section on the Zone which set in the attribute WebPartZoneID for a form. Developers tend to set a fake zone in this attribute. So they trick the sharepoint, it can't find a zone and throws the message during the first display of the page and closes this ListForm Webpart. Voila! - you have a very custom form.
The custom form itself can be with webparts or with controls in it.
No comments:
Post a Comment