WorkflowTransition references WorkflowStates as a reference_item, not a list_string

Created on 3 May 2025, 11 days ago

Problem/Motivation

Module Maintainer was swapping back and forth regarding the base class of the 'from_sid' and 'to_sid' fields of the WorkflowTransition.

Easiest way is the 'list_string' which is defined by the 'options' module:
$fields['to_sid'] = BaseFieldDefinition::create('list_string')
- it allows by default for checkboxes, radiobuttons, select_list widgets
- it allows by default to use the 'allowed_values_function'
- it allows for 'getPossibleOptions()' to return a key->object array, where the object is transformed magically to a string in the widget by the __toString() function.

However, strictly speaking, the from_sid and to_sid WorkflowState fields point to objects, not strings, so they should be defined as:
$fields['to_sid'] = BaseFieldDefinition::create('entity_reference')
But this pollutes the FieldUI in several ways:
- the item is not only displayed as a Workflow field, but also as a 'reference' field
- defaultValues() for the widget fetch ALL existing values not only the valid values for the requested Workflow type.
- the autocomplete widget is enabled, which should not be the case (some might call this a feature).

Therefore, the field must be using a subclass for the 'entity_reference' FieldType:
$fields['to_sid'] = BaseFieldDefinition::create('workflow_state_reference')
to get away with all above problems.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

2.0

Component

Documentation

Created by

🇳🇱Netherlands johnv

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

Comments & Activities

Production build 0.71.5 2024