Reputation: 2516
I built a custom new form for a page and in the schema file I did the following:
<Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="Main" />
So it looks for my custom form, it works fine for new clients I create but ones already in the system still point to the standard new form
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
So I've tried to create an upgrade rule to get the older ones to look at the custom form by doing this:
var list = web.TryGetList("Client Programs");
list.DefaultNewFormUrl = "NewForm.aspx";
list.Update();
But I have a feeling this won't do anything, is there some way to point the old data to the new custom form through the site settings page, or what would I need to add/change in the upgrade rule to get this working?
Update
I should also mention that in the properties for the form I have changed it to look in the hive for the form and made it an elementfile.
Thanks
Upvotes: 1
Views: 1377
Reputation: 639
Existing items are edited by the EditForm.aspx, not from the newform.aspx
You have to duplicate newform.aspx and name it editform.aspx (a displayform.aspx could be created to).
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\YourProject\CustomDisplay.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\YourProject\CustomEdit.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\YourProject\CustomNew.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
</Forms>
For each form,each SharePoint form field have to be tagged with the correct control mode
New Form :
<SharePoint:FormField runat="server" ID="field_YourFieldName" ControlMode="New" FieldName="YourFieldName" />
Edit Form :
<SharePoint:FormField runat="server" ID="field_YourFieldName" ControlMode="Edit" FieldName="YourFieldName" />
Display Form :
<SharePoint:FormField runat="server" ID="field_YourFieldName" ControlMode="Display" FieldName="YourFieldName" />
Upvotes: 1