none
How to create *two* Edit forms for same list/content type?

    Question

  • I have a SharePoint 2013 Visual Studio farm solution that I'm developing that creates a content type, list definition and list instance.  I want to use a custom edit form as the default edit form.  I can define this in the list definition's schema.xml file.  And it works just fine, like I want it to.  BUT I also want to allow people to edit items using the out-of-the-box EditForm.aspx (using a CustomAction).  Is this possible?



    Chris Morelock

    Thursday, March 08, 2018 5:14 PM

Answers

  • So the way to provide multiple Edit Forms (or new or display...) for a list definition is simply to add multiple Form elements, one for each of the edit forms, in the Forms section of the Schema.xml file. For example:

    <Forms>
          <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
          <Form Type="EditForm" Url="EditResponseForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Audits\EditResponseForm.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
          <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
          <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main"  />
        </Forms>
    The EditForm listed first will become the default Edit Form.  It's as easy as that.  I have searched far and near, but I have never seen an example like this, so I just assumed that you couldn't do this. But you can.


    Chris Morelock

    • Marked as answer by cjmore Friday, March 09, 2018 7:31 PM
    Friday, March 09, 2018 7:31 PM

All replies

  • Yes,

    If you have two different content type, you can show them according to your needs

    https://wonderlaura.com/2009/11/12/using-content-types-as-statuses/


    Please remember to click Mark as Answer on the answer if it helps you

    Thursday, March 08, 2018 6:43 PM
  • Yes,

    If you have two different content type, you can show them according to your needs

    https://wonderlaura.com/2009/11/12/using-content-types-as-statuses/


    Please remember to click Mark as Answer on the answer if it helps you

    Thanks Lakshmanan Sethu. Interesting idea that I'll have to remember. This does not meet my requirement though. There will be only one content type; users with appropriate permissions will be able to use the standard EditForm in addition to the default custom form.

    Chris Morelock

    Thursday, March 08, 2018 8:53 PM
  • Hi,

    Add the code into script editor web part into the custom form page to open the OOTB EditForm.aspx page.

    <script src="//code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	$("#DefualtEditForm").click(function(){
    		window.location.href="EditForm?ID="+getUrlParameter("ID");
    	});
    });
    function getUrlParameter(name) {
    	name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
    	var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
    	var results = regex.exec(location.search);
    	return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
    }
    </script>
    <input id="DefualtEditForm" type="button" value="EditForm"/>

    If the EditForm.aspx page not exists, I suggest you create custom form using SharePoint designer 2013, then we can easy switch the custom form page to OOTB form page.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.


    Friday, March 09, 2018 4:01 AM
    Moderator
  • So the way to provide multiple Edit Forms (or new or display...) for a list definition is simply to add multiple Form elements, one for each of the edit forms, in the Forms section of the Schema.xml file. For example:

    <Forms>
          <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
          <Form Type="EditForm" Url="EditResponseForm.aspx" SetupPath="features\$SharePoint.Feature.DeploymentPath$\Audits\EditResponseForm.aspx" UseLegacyForm="True" WebPartZoneID="Main" />
          <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
          <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main"  />
        </Forms>
    The EditForm listed first will become the default Edit Form.  It's as easy as that.  I have searched far and near, but I have never seen an example like this, so I just assumed that you couldn't do this. But you can.


    Chris Morelock

    • Marked as answer by cjmore Friday, March 09, 2018 7:31 PM
    Friday, March 09, 2018 7:31 PM
  • Hi,

    Glad to hear that you solve this issue, thanks for your sharing.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, March 13, 2018 1:28 AM
    Moderator