11

I have 5 columns in the custom list. Out of which only 3 have to displayed in the NewForm.aspx page.

All of the 5 columns have to be displayed on the EditForm.aspx page. While googling, I have come across the following link :

When I implemented the code that was given on this page, I get an error which says that parentNode is not found. Please guide me how can I implement this requirement.

Any other alternatives other than this are also appreciated.

11 Answers 11

9

The best way is to open sharepoint designer and create a new custom "NewForm".

There the complete form is rendered as normal table structure. You can just put "style='display:none'" in <tr> and you are done.

enter image description here

  • When I try to edit my existing form in sharepoint designer, it gives me infopath control and does not allow me to edit it. How can I edit it? Please guide. – Mancy Desaee Sep 24 '13 at 12:13
  • In sharepoint designer go to your list. There you will see an option to create a new form. Just create it and then edit it in advanced mode. You will get the screen as shown above. – Garima Sep 25 '13 at 4:21
  • 2
    This is not a good way to hide field. If later you want to make other changes to new form, nothing will happen automatically - you will have to everything by manually updating your custom new form. Better to use PowerShell (like ReTech have answered). – Kristaps Vilerts Jun 21 '16 at 7:15
27

You can access the field you want to hide via Powershell and set ShowInNewForm to false. This will hide this field in you NewForm

$web = Get-SPWeb webUrl
$list = $web.Lists.TryGetList("Listname")
if($list)
{
    $field = $list.Fields["FieldName"]
    $field.ShowInNewForm = $false
    $field.Update()
}
$web.Dispose()
  • 1
    Thanks. It works good. It would be good if we can add $web.dispose() in the end. – Zakir HC May 21 '15 at 8:46
  • By far the best solution mentioned here! Should be marked as the answer. – Florian Leitgeb Mar 10 '17 at 15:29
4

It's way easier than all of this, go to List Settings, go to advanced settings, "Allow management content types "Yes" go back to list settings. You should see "Content Type" as a link (usually right above columns) click that. It's essentially a view of the form. Now once there you will see a list of all your columns again. Click on the column title, and then on Change Content Type, look at Column Settings. You should see Required, Optional, Hidden. Go ahead and hide. This will keep you from having to use infopath or code it in Sharepoint Designer, and I don't know about your server, but everytime we do a code variation using Infopath it runs much slower on form load time.

  • 5
    -1 This does not work in the context of this question. OP only needs the fields to be hidden on Newform.aspx; they need to be shown on Editform.aspx. Changing the field to Hidden through Content Type settings applies to all three forms. – Dan Henderson Dec 3 '15 at 20:48
2

I would suggest you to use InfoPath 2010. With InfoPath installed in your machine, just by clicking "Customize Form" on the ribbon and it is one of the most useful features in SharePoint 2010.

  • 1
    This is a great approach, if you have SharePoint Enterprise :) – Robert Lindgren Sep 24 '13 at 12:42
1

Add a Content Editor webpart to your page and use following JQuery code to hide the fields.

var feedbackField = $("input[title=Feedback]");
feedbackField.parent().parent().parent().hide();  

The above line of code hides the field named Feedback.

SOURCE

  • I would be careful with this moving forward, it's my understanding (however I haven't seen this in person) that in 2013 and above this code will not work as intended. I'm not sure how accurate this is because I have not coded it myself, however i have colleagues that claim that has been an issue. – Ike Rebout Jan 28 '16 at 5:34
  • Also not a very safe option – Florian Leitgeb Mar 10 '17 at 15:39
1

Another option is to install the free 'SPC3 Show/Hide Fields' feature. This gives you a user interface to easily control which fields are shown on all three form types (display, create, edit) without any custom coding. It is a farm feature, however, so it may not be an available option in every case.

http://spc3.codeplex.com/

0

I just create new forms for everything, and use Designer to remove the fields in the forms I don't want them to display in, then set those forms as the default.

You can use either the Design OR Code view to delete the rows you don't want to display on the New Item form.

  • Please provide an example on how to achieve that from Designer or Code.. You may also provide a link to post which explains how to – Arsalan Adam Khatri Jan 29 '15 at 15:16
0

I don't think it is good idea to create copy of NewForm.aspx for this task. Customized forms are very hard to maintain/support. Marc Anderson created cool function to hide different fields on Edit/New forms: http://sympmarc.com/2012/11/29/easily-hide-columns-on-a-sharepoint-form-with-jquery/

// Function to hide a column's row in the form
function hideColumn(c) {
  $(".ms-formlabel h3 nobr").filter(function() {
    var thisText = $.trim($(this).clone().children().remove().end().text());
 //   alert("::" + thisText + "::");
    return thisText.indexOf(c) === 0 && thisText.length === c.length;
  }).closest("tr").hide();
}

this is for on-premise. in cloud for me worked

$(".ms-formlabel span nobr")

instead of

$(".ms-formlabel h3 nobr")
  • This is not a good idea, because it is very easy to manipulate – Florian Leitgeb Mar 10 '17 at 15:25
  • Hmm, not sure we understand each other) I used different approaches and also created custom forms before. But now I try to use javascript injections only. This function hides any field if You pass display name like hideColumn("Field Display Name"). Also think that SPD will be deprecated in future versions, so js is the best way now – Gennady G Mar 14 '17 at 11:08
  • It is very easy to open developer tools in browser and enter some value to hidden fields. This could be a workaround but definitely not best practice. – Florian Leitgeb Mar 15 '17 at 10:24
  • If You mean "best practice" === "more secure", than maybe. In SharePoint there are many ways to solve same problem. – Gennady G Mar 15 '17 at 12:04
  • And what if the javascript or even jquery was not able to load? People are going to see hidden fields and are able to enter values there. It would break the whole concept... It is also possible that you are going to have a delay when loading your Javascript. In my opinion, it should be not one of the "many ways". – Florian Leitgeb Mar 15 '17 at 12:10
0

You can use

var field = $("input[title*=Name of the field]");
field.parent().parent().parent().hide(); 

The * in title is needed because SharePoint 2013 uses "Required Field" on required fields.

0

you can set below property values based on your requirement ShowInDisplayForm="TRUE" ShowInNewForm="FALSE" ShowInEditForm="FALSE"

 <Field DisplayName="testColoumn" Type="Text" Group="_Hidden" StaticName="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" Name="Title" ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" FromBaseType="TRUE" Required="False" ShowInDisplayForm="TRUE" ShowInNewForm="FALSE" ShowInEditForm="FALSE"> </Field>
-1
<style>
    .ms-formtable tr:nth-child(8){display:none;}
</style>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.