Wednesday, September 3, 2008

Create a custom list form for a SharePoint list

  1. Open your site in SharePoint Designer.
  2. Browse to your list and open the 'NewForm.aspx' web form.
  3. Go File -> Save As... and give the form a new name such as 'NewForm2.aspx'.
  4. Hide the default List Form Web Part from the page (do not delete it!!).
    1. Right click the List Form Web Part -> Web Part Properties -> expand LayoutHidden. -> check
  5. Go Insert > SharePoint Controls -> Custom List Form.
  6. In the List or Document Library Form dialog, select the appropriate list, content type and type of form.
  7. Click OK and a new Data Form Web Part is added with controls representing all the fields from the list (in my environment all the controls show "Error Rendering Control" but this does not affect the final result).
  8. In the newly added Data Form Web Part, delete the rows containing fields not to be shown to the user (ensure that fields being removed are not required fields without default values as this would prevent the user from submitting the form).
  9. At this point, you can do other customisation such as rearranging the fields if you wish.
  10. Save the site.

To make the new form the default form:

1. Open the site in SharePoint Designer.
2. Right click the list in the Folder List and select Properties.
3. Go to the Supporting Files tab.
4. Use the Browse button to enter the path to your new Edit item form.

Note: To redirect after the form is submitted, use the following syntax in your misc links that point to the new form...

http://sps.com/Lists/YourList/myForm.aspx?Source=http://sps.com/help.htm