Add hook for checking field definition access

Created on 7 July 2025, 3 months ago

Problem/Motivation

It is difficult, currently, to hide a core field definition from a user and apply access controls as webform submissions bypass Drupal's usual field access hooks.

It would be a great feature to add a hook so that certain base definitions are able to be hidden in various contexts. The ones I see most relevant being:
- the results table
- wherever entities are printed (downloads etc)

Steps to reproduce

1. Try to hide remote IP conditionally from results table and entity print

Proposed resolution

Add in a hook in the checkFieldDefinitionAccess function to allow other modules to unset field definitions and remove them from display.

Remaining tasks

Add tests.

User interface changes

N/A

API changes

New hook: hook_webform_submission_field_definition_access_alter().
Ability to unset field definition keys and hide them from results tables/exports.

Data model changes

N/A

✨ Feature request
Status

Active

Version

6.3

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom littlepixiez

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @littlepixiez
  • πŸ‡¬πŸ‡§United Kingdom littlepixiez

    I will need to add a test to this, but would love feedback on whether the webform community think this is a good idea and whether this hook should touch logic in the results table as well as in the original function.

  • Pipeline finished with Success
    3 months ago
    Total: 501s
    #541006
  • πŸ‡¬πŸ‡§United Kingdom littlepixiez

    Also adding a patch here for Webform 6.2.x, as webform.api.php isn't using namespaced vars in that version.

  • Pipeline finished with Canceled
    3 months ago
    Total: 145s
    #560708
  • Pipeline finished with Failed
    3 months ago
    Total: 933s
    #560713
  • Pipeline finished with Failed
    3 months ago
    Total: 460s
    #560768
  • Pipeline finished with Failed
    3 months ago
    Total: 467s
    #560889
  • Pipeline finished with Failed
    3 months ago
    Total: 382s
    #560901
  • Pipeline finished with Success
    3 months ago
    Total: 491s
    #560922
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Any access control improvement will need some test coverage.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    liam morland β†’ made their first commit to this issue’s fork.

  • Issue was unassigned.
  • Status changed to Closed: won't fix about 1 month ago
Production build 0.71.5 2024