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.
In field_permission_example.module the field_permission_example_entity_field_access
function is checking for the correct field name using $field_definition->getType()
, which returns the field type. I believe the getName() method should be used instead to return the field name on line 99.
Comments
Comment #2
michaellenahan CreditAttribution: michaellenahan at erdfisch commentedActually, it's correct as it is. The code in field_permission_example_entity_field_access() should only run when the type of field is a fieldnote. We don't actually care about what the name of the field is.