diff --git a/src/Entity/WorkflowTargetEntity.php b/src/Entity/WorkflowTargetEntity.php index a302de69ac6b4b0ae1703d191e94babfb81a134f..617ca88532826ddad8900a4fca21be235a9ee779 100644 --- a/src/Entity/WorkflowTargetEntity.php +++ b/src/Entity/WorkflowTargetEntity.php @@ -106,7 +106,7 @@ class WorkflowTargetEntity { * @return string * The ID of the creation State for the Workflow of the field. */ - private static function getCreationStateId(EntityInterface $entity, $field_name) { + public static function getCreationStateId(EntityInterface $entity, $field_name) { $sid = ''; /** @var \Drupal\Core\Config\Entity\ConfigEntityBase $entity */ diff --git a/src/Plugin/Field/FieldType/WorkflowItem.php b/src/Plugin/Field/FieldType/WorkflowItem.php index 51a12442c3b06f588f12aefebd0e7d8ba499fd10..0ff9d269310ecbf7cf7c5a34d6acf31d8125d308 100644 --- a/src/Plugin/Field/FieldType/WorkflowItem.php +++ b/src/Plugin/Field/FieldType/WorkflowItem.php @@ -12,6 +12,7 @@ use Drupal\Core\Url; use Drupal\options\Plugin\Field\FieldType\ListItemBase; use Drupal\workflow\Entity\Workflow; use Drupal\workflow\Entity\WorkflowState; +use Drupal\workflow\Entity\WorkflowTargetEntity; use Drupal\workflow\Entity\WorkflowTransition; use Drupal\workflow\Entity\WorkflowTransitionInterface; @@ -285,7 +286,10 @@ class WorkflowItem extends ListItemBase { // Create a transition, to pass to the form. $entity = $this->getEntity(); $field_name = $this->getParent()->getName(); - $current_sid = $this->value; + $current_sid = $entity->isNew() + ? WorkflowTargetEntity::getCreationStateId($entity, $field_name) + : $this->value; + if (!$current_sid) { return $transition; }