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.
Currently, access to the field is done in the widget itself, which is not such a good idea imo.
A problem I experienced, I had the field in a vertical tab (fieldgroup), and for users without access to the field, the fieldgroup would appear empty (while it should be hidden.
Checking the html, I saw an empty html container for the radioactivity field.
This can be fixed by adding the following implementation of hook_field_access:
/**
* Implements hook_field_access().
*/
function radioactivity_field_access($op, $field, $entity_type, $entity, $account) {
if ($field['type'] == 'radioactivity' && $op == 'edit') {
return user_access("edit radioactivity");
}
return TRUE;
}
Comment | File | Size | Author |
---|---|---|---|
#1 | radioactivity_field_access-1941734-1.patch | 1.52 KB | rv0 |
Comments
Comment #0.0
rv0 CreditAttribution: rv0 commentedtypo
Comment #1
rv0 CreditAttribution: rv0 commentedGot burned by this again. Adding a patch.
This also corrects the documentation of the widget function and removes the redundant access check there.
Comment #2
rv0 CreditAttribution: rv0 commentedbump
Comment #3
rv0 CreditAttribution: rv0 commentedbump^2
Comment #5
Sutharsan CreditAttribution: Sutharsan at LimoenGroen commentedBetter late then never ;)