Sometimes, it is necessary to override the default list edit forms provided by SharePoint. A common example is the “Title” column. In most cases, we design our lists to have some field that is a single line text field that we can map to the Title field. The reason that has to be done is because SharePoint throws the Title field into the list by default. This behavior cannot be changed, so we have to work around it.
In some cases, we don’t have any single line text fields in the list, and in such cases, the only thing we can do is to IGNORE the field. It’s pretty hard to ignore the field if we still see it though. This is when we would want to override the NewForm.aspx and EditForm.aspx pages.
Another example would be when we are designing a Support Request type of form. In such a case, the user filling out the form doesn’t care about all the tracking information we tie to the form, such as who it’s assigned to etc. All they care about is to give us a description of the error. A minimalist approach would have the user making the support request fill out just a Title and Description of the error.
If the form the user is filling out has lots of other fields in it, it can be confusing for the user. This is another good example of when we would want to override at least the NewForm.aspx page.
To override default forms and hide fields:
- Begin by launching SharePoint Designer.
- Using the File/Open Site menu, open the target site.
- As always, backup, Backup, BACKUP!!!
- Navigate to the target list.
- You should see the forms AllItems.aspx, DispForm.aspx, EditForm.aspx and NewForm.aspx in the listing.
- Right click the form you’re about to edit.
- On the popup menu, click “Copy”.
- Now right click somewhere in the white space of the listing.
- On the popup menu, click “Paste”.
- The forms list should now show a backup copy of the form we’re about to edit e.g. “NewForm_copy(1).aspx” if we backed up the NewForm.aspx.
- Double click the NewForm.aspx to open it. It should look like this:
- What we want to do, is insert a new “Custom List Form” in order to control the controls used on the page.
- Select the list form that is there by clicking on it. The entire thing should be highlighted, as above.
- VERY IMPORTANT!!! Do NOT miss this step. With the list form selected, press the RIGHT ARROW key on your keyboard, one time.
- This moves the cursor just to the right of the list form. It also unselects the list form. This is the exact position where we wish to insert our custom list form content.
- From the menu, select “Insert/SharePoint Controls/Custom List Form”.
- In the modal window that pops up, change the “List or document library…” dropdown to target your current list.
- Leave the “Content type…” dropdown value as “Item”.
- Check the radio button for the type of form to insert. In our example, we’re overriding the NewForm.aspx so we select the first value.
- Click “OK” to insert the content.
- Your page should now look like this with the standard list form content on top and the new custom list form content right below it:
- Scrolling to the bottom of our list, we find the controls we wanted to remove from the NewForm.aspx.
- Select the entire row.
- Right click on the selected row.
- On the popup menu, click “Delete/Delete Rows”.
- The row and it’s controls should now be missing from view.
- Now that we have the custom content ready, we need to hide the default content.
- IMPORTANT!!! DO NOT DELETE THE DEFAULT LIST VIEW CONTENT!
- Select the default list content by clicking on it.
- Now click the “Split” view button below the preview window. This should show you both the preview AND the source code behind it. Note the <IsVisible> node value of “true”.
- Double click on the <IsVisible> line to edit it.
- Change the value to “false”.
- Click the “Save” icon to commit your changes.
- If it’s the fist time editing the form, you will be prompted with this warning:
- The warning basically just warns that the list is being customized, which we already know because that was our intention from the outset.
- Click “Yes” to continue.
- Now when you go to add a new item to the list, the new form we just designed, is used and the fields hidden.
Cheers
C
No comments:
Post a Comment
Comments are moderated only for the purpose of keeping pesky spammers at bay.