Warning: Undefined array key in WorkflowDefaultWidget->formElement() line 87

Created on 20 December 2023, over 1 year ago

Problem/Motivation

When accessing the node create form with a workflow field i get the error

Warning: Undefined array key "field_state" in Drupal\workflow\Plugin\Field\FieldWidget\WorkflowDefaultWidget->formElement() (line 87 of modules/contrib/workflow/src/Plugin/Field/FieldWidget/WorkflowDefaultWidget.php).

Steps to reproduce

Create workflow and add field of type "Workflow state" to the workflow. On the edit tab configure "Select List" under "How to show the available states". Now add field of type "Workflow state" to the node. On the node form display select "Workflow transition form".

Proposed resolution

See commit

๐Ÿ› Bug report
Status

Active

Version

1.7

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany fox_01

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

Merge Requests

Comments & Activities

  • Issue created by @fox_01
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    chetan 11 โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    Please check the above raised MR.

  • Status changed to Postponed: needs info over 1 year ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    The change seems fairly simple.

    Bu ti am curious about the root cause. This can only happen if you have added 'additional fields' to the workflow.
    Did you?
    Please give details.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    This would be the shorter version of the patch:

    @@ -84,7 +82,7 @@ class WorkflowDefaultWidget extends WidgetBase {
         // Determine and add the attached fields.
         $attached_fields = WorkflowManager::getAttachedFields('workflow_transition', $wid);
         foreach ($attached_fields as $key => $attached_field) {
    -      $element[$key] = $workflow_form[$key];
    +      $element[$key] = $workflow_form[$key] ?? 'Default Value';
         }
    
  • Status changed to Closed: outdated 4 days ago
Production build 0.71.5 2024