I have a picture library and added few fields to it. When i click add new item from picture library, the EditForm.aspx appears after uploading the picture. This form contains many fields of which I want to hide Title, Date Picture Taken, Description, and Keyword. In short the EditForm should contain only Name, Preview and the columns that I have added. Is it possible to hide the other columns?
2 Answers
Simplest way is probably to go to list Settings -> Advanced Settings and turn on Allow Management of Content Types. You will then be able to select the content type (Picture) in the list settings. From here you will see the columns included in that content type. Click on a column and you can then make it hidden so it will now not appear on your forms.
Yes it is. You can write some custom code in a feature reciever or you can run a powershell script:
function ShowHideFieldInForms([string]$fieldId,
[Microsoft.SharePoint.SPContentType]$ct,
[Microsoft.SharePoint.SPList]$list,
[System.Boolean]$showInEdit, [System.Boolean]$showInDisplay){
$fieldGuid = GetGuid -id $fieldId
$field = $list.Fields[$fieldGuid]
$field.ShowInEditForm = $showInEdit
$ctFieldLink = $ct.FieldLinks | Where { $_.Id -eq $field.Id }
if ($ctFieldLink -ne $null){
$ctFieldLink.ShowInDisplayForm = $showInDisplay
$ct.Update()
}
Write-Host "The Field :" $field.Title " ShowInEditForm property is "$showInEdit "on the list :" $list.Title
}
To use it create an array string of fields:
$fieldsForEditFormHiding = @("436a0ca5-ff06-4428-a2fe-b872ee88c75f", # some field you want to hide.
"5eb4a88e-bfa4-4746-8999-bfdd544a3ef4") # another field you want to hide
foreach ($fieldId in $fieldsForEditFormHiding)
{
$ct = $list.ContentTypes["YOUR CONTENT TYPE NAME"]
ShowHideFieldInForms -list $list -ct $ct -fieldId $fieldId -showInEdit $false -showInDisplay $true
}