Skip to content

Knowledge Field Module

The Knowledge Field module provides custom field types used by Knowledge entities. It is a required dependency of the main Knowledge module and is automatically enabled when Knowledge is installed.

Overview

This submodule defines the Competency Roles field type (knowledge_competency_role), which stores role progression data on the Knowledge Competency entity. The field is used internally by the competency system and is not exposed in the Field UI.

Components

Field Type: Competency Roles

  • Plugin ID: knowledge_competency_role
  • Class: Drupal\knowledge_field\Plugin\Field\FieldType\KnowledgeCompetencyRoleItem

Stores progression data for each competency role (Candidate, Contributor, Publisher):

Property Type Description
role string The competency role identifier
correct int Number of competency criteria met
total int Total competency criteria for this role
proposer int User ID of the coach who proposed the promotion
approver int User ID of the approver
proposed int Timestamp when promotion was proposed
approved int Timestamp when promotion was approved

Field Widget

  • Plugin ID: knowledge_competency_role
  • Class: Drupal\knowledge_field\Plugin\Field\FieldWidget\KnowledgeCompetencyRoleWidget

Provides the edit form for competency roles:

  • Role name and correct/total counts
  • Entity autocomplete for Coach (proposer) and Approver
  • Aggregates values from boolean competency fields that have the competency_role third-party setting (from Knowledge) assigned

Field Formatter

  • Plugin ID: knowledge_competency_role
  • Class: Drupal\knowledge_field\Plugin\Field\FieldFormatter\KnowledgeCompetencyRoleFormatter

Renders the competency role values in view mode.

CompetencyField Helper

  • Class: Drupal\knowledge_field\Helper\CompetencyField

Static helper that maps competency entity field definitions to roles:

CompetencyField::roleFields($field_definitions)

Returns an array keyed by competency role, with each value an array of field names. Only boolean fields with the knowledge.competency_role third-party setting (not _none) are included.

Integration with Knowledge

The main Knowledge module:

  1. Defines the roles base field on knowledge_competency using this field type
  2. Assigns competency_role via third-party settings on boolean fields in the Competency Settings form
  3. Uses CompetencyField::roleFields() in forms and the Competency entity to map fields to roles

Requirements

  • Drupal: 10.3+ or 11+ or 12+
  • Dependencies: Main Knowledge module (required)

See Also