Skip to content
Snippets Groups Projects
Commit 7543cf61 authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #3508337 by haicao-devpanel, johnv, spiderman: Workflow doesn't...

Issue #3508337 by haicao-devpanel, johnv, spiderman: Workflow doesn't recognize state change first time
parent 5d6c7733
Branches
Tags
No related merge requests found
Pipeline #450067 passed with warnings
......@@ -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 */
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment