Now required that
a field need to be hidden from normal user, and even the author, but not administrator, and also code functions change put value to,
which mean we can use function to insert data to it or load data from database to it,
but now allow user to see or to input value.

Some one suggested the following,
Can some one help us to understand the difference between
-disabled
-access
-hidden
-element-invisible

Thanks a lot.
after thinking, seems that access is a good idea.

Comments

cmsMinds’s picture

WorldFallz’s picture

It's a great module and works brilliantly, but I find it a little heavy just to hide fields as described on the op. For that, I just use hook_form_alter and set the '#access' attribute to FALSE or the '#disabled' attribute to 'TRUE' depending on whether I want to hide it or show it disabled.

klidifia’s picture

It stops it being rendered completely. To actually hide it why not set a class, maybe something that already exists in Drupal such as:

['#attributes']['class'][] = 'element-hidden';
duartebriz’s picture

This is the only option working if you want to set the value of the field via javascript. A beer for klidifia.

vinoth.babu’s picture

use "hook_form_alter" to hide the particular form field


function modulename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'contenttypename_node_form') {
    $form['your_field_name']['#access'] = 0;
  }
}


vaidas_a’s picture

Field_extrawidgets works fine for this purpose.

dx007’s picture

@vinoth.babu > Works great in a custom module. Thanks!
But how to make this code works with an admin theme field. Precisely, if I want to hide a field in the adminimal theme based on the url? How am I supposed to do that?

magendiran’s picture

Thanks @vinoth.babu,

It is working fine.