How to hide fields on display form?

Just wondering if someone could help me hide number fields if they are empty. I have code but it's not working correctly. Works with forms designer but not Plumsail Forms. I have tried many different terms for find.

fd.spRendered(function() {

$('.FieldTable tr').each(function () {
$(this).find('Input').eq("").each(function () {
if ($(this).text().trim() == "") {
$(this).closest("tr").remove();
}
});
});

});

Hello @ryankohn,

You can hide any field with this code:

fd.spRendered(function() {

     $(fd.field('FieldName').$parent.$el).hide()

});

You also might be interested in 'Manipulate fields dynamically' article.

Would you happen to know how to hide fields in a table if they are empty on the display form? I have one form that has some code and it works on that one but not the other one with number fields. Here is that code:

fd.spRendered(function() {

$(".FieldTable tr:gt(1)").each(function(){
if($(this).children('td').first().find("*").val() == "")
$(this).hide();
})
});

@ryankohn,

Sorry for the delay in reply. We had a national holiday.

What control you are using in the form: Data Table image or List or Library image ?

Do you want to hide the line or the column?

Could you please share the screenshot of the form, just to make sure we are on the same page.

No problem. Thanks for replying. I have a screenshot of my partial form.


So, in the screenshot, the REQ QTY column is a SharePoint number field. I would like to hide the row of a blank quantity. So in this screenshot, I would like to show only the row, Manila Letter Size (100/BX) and hide the rest on a display form. I hope that makes sense? In forms designer, we have the code: $('.FieldTable tr').each(function () {
$(this).find('.fd_control').eq(0).each(function () {
if ($(this).text().trim() == "") {
$(this).closest("tr").remove();
}
});
});

and that is working, but I know Plumsail Forms is different. Thank you for helping!

I finally got this working after hours of frustration. I had to change the find field from .fd_control to .col-form-label. Just one little thing makes a difference. Thanks!

1 Like