- Issue created by @johnv
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.
Active
2.0
Documentation