Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By qqboy on
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
hide field
Hi,
Try the below listed module,
https://www.drupal.org/project/field_permissions
Thanks
Raj Laddha
cmsMinds
rajesh@cmsminds.com
Drupal Development - North Carolina
_
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.
Access does not hide the field
It stops it being rendered completely. To actually hide it why not set a class, maybe something that already exists in Drupal such as:
Works with JS
This is the only option working if you want to set the value of the field via javascript. A beer for klidifia.
use "hook_form_alter" to hide
use "hook_form_alter" to hide the particular form field
thanks. a .lot .thanks.
thanks. a .lot .thanks.
https://www.drupal.org/project/image_captcha_indicator
https://www.drupal.org/project/ext_js
field_extrawidgets
Field_extrawidgets works fine for this purpose.
Works great in a custom
@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?
Thanks @vinoth.babu,
Thanks @vinoth.babu,
It is working fine.