Methods of Hiding column entry tab from newform.aspx and editform.aspx forms
Method 1 : The first solution is to customize NewForm.aspx from SharePoint Designer and replace the default list form with Custom List Form, in which you can remove the fields you don't need.
Method 2 : Next is to customize NewForm.aspx and add a JavaScript code that hides the whole row the field is placed.
We have implemented method 2 for the system implementation. We will discuss it in detail.
getTagFromIdentifierAndTitle
The most important part of our solution is the “getTagFromIdentifier” function. This function finds the HTML element rendered by a given SharePoint FormField control. It takes the following parameters:
- tagName – The name of the tag rendered in the form’s HTML
- identifier – The string associated with the SharePoint type of the relevant field
- title – The value of the relevant HTML tag’s “title” attribute, which also matches the field’s display name
Here’s a partial table of SharePoint column types and their corresponding “identifiers” and “tagNames”:
SharePoint Field Type | Identifier | tagName |
Single Line of Text | TextField | input |
Multiple Lines of Text | TextField | textarea |
Number | TextField | input |
Currency | TextField | input |
Choice (dropdown) | DropDownChoice | select |
Lookup (single) | Lookup | select |
Lookup (multiple) | SelectCandidate; SelectResult | select |
Yes/No | BooleanField | input |
Date Time | DateTimeFieldDate | input |
For hiding “Assigned to” field:: getTagFromIdentifierAndTitle("div", "", "People Picker");
JavaScript code :
<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideFields");
function hideFields() {
var control = getTagFromIdentifierAndTitle("TAGNAME","IDENTIFIER","FIELD NAME");
control.parentNode.parentNode.parentNode.style.display="none";
}
function getTagFromIdentifierAndTitle(tagName, identifier, title)
{
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i[tags.length; i++)
{
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == ""
tempString.indexOf(identifier) == tempString.length - len))
{
return tags[i];
}
}
return null;
}
<>[/script]