How to create a workflow state field programmatically? I have my custom entity created, workflow module installed and now I would like to create a workflow state field on my entity. I know I have to do it in the src/Entity/MyEntity.php class in my module, but where do I get all those field settings for this particular field type for the BaseFieldDefinition::create method?

I have somehow managed to put this field definition in my entity class:

$field['workflow'] = BaseFieldDefinition::create('workflow')
  -&gt;setLabel(t('Workflow'))
  -&gt;setDescription('Workflow entity')
  -&gt;setSetting('workflow_type', 'test_workflow');


But it does not add a field to my entity. Thanks.

EDIT: test_workflow is existing workflow.
You should do it with entity_reference and target_type to be workflow, it should work like that. And with handler_settings you can set your type of workflow.