To hide columns in SharePoint List Forms like NewForm.aspx or EditForm.aspx seems to be a very common task.
Usually you can create a custom form with SharePoint Designer or enable content types on the list and choose to hide the column in all forms.
Last but not least my favorite way with PowerShell and my PowerShell Shell Scripts:
$web = get-spweb http://localhost/websites/myweb
$list = $web.Lists["listTitle"]
$field = $list.Fields["columnTitle"]
$field.ShowInDisplayForm = $false
$field.ShowInEditForm = $false
$field.ShowInListSettings = $false
$field.ShowInVersionHistory = $false
$field.ShowInViewForms = $false
$field.ShowInNewForm = $false
$field.Update($true)
$web.Dispose()
Certainly you can do much more with SPField...
1 comment:
Excellent example! One thing to note: you're leaking the SPSite object created by Get-SPWeb. If you call $web.Site.Dispose(), $web will be Disposed automatically.
Post a Comment