Customizing the SharePoint forms using Infopath is easy in SharePoint 2010. You have a “Customize Form” option under List Tools -> Lists in the ribbon when you are in the list view. Below screenshot shows that option (highlighted in red).
On selecting this option, the form(Edit) is opened in Infopath Designer. Here you will be doing the changes in one infopath form(Edit) but, once you publish the form, the changes will be reflecting in all the three forms (New/Display/Edit).
So what if you want to edit three different forms in three different ways? Say New form should have all columns displayed, edit form should have some fields disabled where user cannot modify the values and display form having a different layout altogether.
Infopath solves this purpose by providing Views. We will be creating 3 views for each of the forms (New/Edit/Display). Follow the below steps to create separate views for each form.
- In the InfoPath designer, where your form is opened, , click on Page Design tab on the ribbon.
- You would be able to see the list of views available as a drop-down and also an option to create New View. You will be already having a view named Edit item (default) displayed in the drop-down.
- Already having a view for Edit form, we have to create 2 new views for New & Display. Click on New View.
- In the pop up opened type the name of the view(say Display Item) and click OK.
- Now you have an empty view, where you can add fields(from right side pane displaying fields from datasources), modify the layouts, adding rules, hiding columns. The changes you do in this view is going to affect only this view. If you want to replicate the views, just select all & copy the contents from one view & paste it in your new view.
- You can create another view (New Item) following the steps 3-5.
- Once you have created the views and done with your changes, publish the form.
- Now having 3 views for 3 different forms, you need to make your SharePoint list aware that which form to use which view.
- Open the list in SharePoint Designer, in the lists detail page, under Forms section, generally you will see DispForm.aspx, NewForm.aspx, EditForm.aspx. In addition to that since you have edited this list in infopath you will see 3 more forms namely displayifs.aspx, newifs.aspx & editifs.aspx.
- You need to set your views for each of this form. For each of the forms do the following steps.
- Open the form, select the form(highlighted in below snapshot), right click and select properties.
- In the properties window opened, under Misc header, set the DefaultView value to the view name you have created.
- You will be setting the values as below
Form Name Default View Name displayifs.aspx Display Item editifs.aspx Edit item newifs.aspx New Item
- Now browse the list in IE to see different views set for different forms.