Thursday, February 5, 2009

Hiding Locked Fields (and hiding tabs)

It's been well posted about hiding fields and tabs using javascript:
Hiding the 2nd tab can be done with js in the onload event: = 'none';

Hiding a field (must know the field ID): = 'none';

I did a bunch of this for various reasons including getting fields to conditionally appear/disappear, hiding tabs that can't be removed for some reason (but are of no use to the implementation) and so forth.

At one point I needed the "Price Per Unit" field. It's locked on the form and the only way I could see to hide it was with javascript. The field hid well, but then I couldn't remove the "$". It was an element called "priceperunit_sys". I tried lots of things, then decided to move it to a new tab and simply hide the tab.

I realized this was a MUCH BETTER solution than hiding each field individually. In this way, I now have a "Hidden" tab that holds all the fields I don't want to display to my users. The advantage is that if I (or anyone else) needs to bring the fields back, they don't need to muck around in the code. They simply move them to a visible tab.

Of course...most fields can be removed, some you may just want hidden because they're used for calculations and may never be shown, but I just stumbled across this and wanted to share.

No comments: