自定义 SharePoint 列表模板中的字段未呈现列表项表单
我定义了一个包含以下字段的自定义列表模板:
<Fields>
<Field Type="Text" DisplayName="Sub-Title" Name="SubTitle" StaticName="SubTitle" ShowInNewForm="TRUE"
ShowInEditForm="TRUE" ShowInViewForms="TRUE">
</Field>
<Field Type="URL" DisplayName="Header Image" Name="HeaderPicUrl" StaticName="HeaderPicUrl" ShowInNewForm="TRUE"
ShowInEditForm="TRUE" ShowInViewForms="TRUE">
</Field>
<Field Type="Note" RichText="True" RichTextMode="FullHtml" IsolateStyles="True" NumLines="5" Name="Summary" DisplayName="Summary"
StaticName="Summary" Sortable="False" ShowInNewForm="TRUE" ShowInEditForm="TRUE" ShowInViewForms="TRUE">
</Field>
<Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Type="Note" RichText="TRUE" RichTextMode="FullHtml" IsolateStyles="TRUE"
NumLines="45" Name="Body" DisplayName="$Resources:core,camlid2;" Sortable="FALSE"
SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body">
</Field>
<Field ID="{6a09e75b-8d17-4698-94a8-371eda1af1ac}" Type="DateTime" Name="Expires" DisplayName="$Resources:core,camlid3;"
Format="DateOnly" FromBaseType="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Expires">
</Field>
</Fields>
请注意,ShowInNewForm
、ShowInEditForm
和 ShowInViewForms
属性均设置为 正确
。当我从部署的模板创建列表时(我从 VSeWSS 1.3 中执行此操作),该列表具有正确的字段,但新的项目表单根本不呈现自定义字段。有谁知道为什么会这样吗?我是否必须完全自定义 ListFormWebPart
加载的控件模板?这是否违背了 ListFieldIterator
控件的目的?
编辑:
此外,schema.xml 文件的末尾有以下内容:
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" WebPartZoneID="Main"/>
<Form Type="EditForm" Url="EditForm.aspx" WebPartZoneID="Main"/>
<Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="Main"/>
</Forms>
I've defined a custom list template with the following fields:
<Fields>
<Field Type="Text" DisplayName="Sub-Title" Name="SubTitle" StaticName="SubTitle" ShowInNewForm="TRUE"
ShowInEditForm="TRUE" ShowInViewForms="TRUE">
</Field>
<Field Type="URL" DisplayName="Header Image" Name="HeaderPicUrl" StaticName="HeaderPicUrl" ShowInNewForm="TRUE"
ShowInEditForm="TRUE" ShowInViewForms="TRUE">
</Field>
<Field Type="Note" RichText="True" RichTextMode="FullHtml" IsolateStyles="True" NumLines="5" Name="Summary" DisplayName="Summary"
StaticName="Summary" Sortable="False" ShowInNewForm="TRUE" ShowInEditForm="TRUE" ShowInViewForms="TRUE">
</Field>
<Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Type="Note" RichText="TRUE" RichTextMode="FullHtml" IsolateStyles="TRUE"
NumLines="45" Name="Body" DisplayName="$Resources:core,camlid2;" Sortable="FALSE"
SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body">
</Field>
<Field ID="{6a09e75b-8d17-4698-94a8-371eda1af1ac}" Type="DateTime" Name="Expires" DisplayName="$Resources:core,camlid3;"
Format="DateOnly" FromBaseType="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Expires">
</Field>
</Fields>
Note that the ShowInNewForm
, ShowInEditForm
, and ShowInViewForms
properties are all set to TRUE
. When I create a list from the deployed template (I'm doing this from VSeWSS 1.3), the list has the correct fields, but a new item form doesn't render the custom fields at all. Anyone know why this would be so? Do I have to fully customize the control templates loaded by the ListFormWebPart
Doesn't that defeat the purpose of the ListFieldIterator
control?
Edit:
Also, the end of the schema.xml file has this bit:
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" WebPartZoneID="Main"/>
<Form Type="EditForm" Url="EditForm.aspx" WebPartZoneID="Main"/>
<Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="Main"/>
</Forms>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚遇到了非常相似的事情。 ListFieldIterator 未呈现自定义字段。该列表基于自定义列表定义和自定义内容类型,并包含自定义列表表单。自定义字段显示在内容类型以及列表的设置页面中。自定义列表表单是现成的 (12\Template\Pages\)form.aspx 文件的副本。
内容类型包含 FieldRef 标签 ala:
在一些地方建议使用这种格式,例如 Furuknap 的 构建 SharePoint 用户体验(第 261 页)。
在中添加 Name 属性标签解决了这个问题。
根据这一经验,我计划始终将 Name 属性包含在自定义内容类型的 FieldRef 元素中。希望这可以节省其他人的时间。
I just ran into something very similar. Custom fields were not being rendered by the ListFieldIterator. The list was based on a custom list definition and a custom content type and included custom list forms. The custom fields showed up in the content type as well as from the settings page of the list. The custom list forms were copies of the out-of-box (12\Template\Pages\)form.aspx file.
The content type contained FieldRef tags ala:
This format is suggested in a few places, e.g. Furuknap's Building the SharePoint User Experience (pp. 261).
Adding the Name attribute in the <FieldRef> tag fixed the issue.
Based on this experience I plan on always including the Name attribute in the FieldRef elements of custom content types. Hope this saves someone else some time.
当您说您使用此处列出的字段创建了列表模板时,它们是否属于内容类型?如果是,内容类型中列的定义是否与 schema.xml 中字段的定义匹配?
更改 schema.xml 后是否重新创建了列表?
编辑:
要包含在 schema.xml 中的字段。如果这些字段不存在,而仅在您定义列的位置,那么这可能就是您创建新项目时它们不会出现在 newForm.aspx 中的原因。
When you say that you created your list templates with the fields listed here, do they belong to a content type? If so, does the definition of the columns in the content type match the definition of the fields in the schema.xml?
Did you re-create the list after making the changes to the schema.xml?
EDIT:
Fields to include in the schema.xml. If the fields aren't there but are only where you defined your columns, then that's probably why they don't appear in the newForm.aspx when you create a new item.