Drupal - How to hide data in "edit content"

66 views Asked by At

I have a drupal site in which we have multiple custom data types. some of the data in these types we want to be able to check and edit, but not to people who happen to be walking by. i have done the following:

  • disabled visibility of the data in the view content page for the content type
  • only allowed users with a certain permission to edit this data type.

On the "edit content" page i want one of two things for the field containing the data mentioned:

  • hide the text with dots as seen with passwords
    • until it is hovered over whereupon the actual text is seen
  • hide it in a peek/show box

<script language="JavaScript">
function ShowHide(divId)
{
if(document.getElementById(divId).style.display == 'none')
{
document.getElementById(divId).style.display='block';
}
else
{
document.getElementById(divId).style.display = 'none';
}
}
</script>
</head>
<body>
<a onclick ="javascript:ShowHide('HiddenDiv')" href="javascript:;"> Show/Hide</a>
<div class="mid" id="HiddenDiv" style="DISPLAY: none" >
This text was hidden
</div>

1

There are 1 answers

1
user3551708 On

Don't use front end JavaScript, do a hook_form_alter on the page that you need to edit. For more information, please read the drupal documentation.