Currently, the Workflow configuration has an option to use the Workflow name as the title of the Workflow form. However, this title is not reflected in the Workflow comment form, which hard codes "workflow" in multiple places. This creates a disconnect for users.

For instance, I have a workflow called Trip Status, which is enabled as the field title. However the comment form title reads, "Workflow comment", and #description reads, "A comment to put in the workflow log. " My users do not know what a "workflow" is, so wouldn't understand that the workflow log has anything to do with the Trip Status. This can be mitigated with more detailed help text when I configure the field, but it shouldn't be necessary, as the word "workflow" should use the workflow name everywhere within the same form ( if the workflow is configured to use the workflow name ).

After looking at the Workflow module, I think the workflow comment is controlled by /src/Element/WorkflowTransitionElement.php near line 358:

    // This overrides BaseFieldDefinition. @todo: apply for form and widget.
    $element['comment'] = [
      '#type' => 'textarea',
      '#required' => $settings_comment == '2',
      '#access' => $settings_comment != '0', // Align with action buttons.
      '#title' => t('Workflow comment'),
      '#description' => t('A comment to put in the workflow log.'),
      '#default_value' => $transition ? $transition->getComment() : '',
      '#rows' => 2,
    ];

I believe this should be changed to:

    // This overrides BaseFieldDefinition. @todo: apply for form and widget.
    $element['comment'] = [
      '#type' => 'textarea',
      '#required' => $settings_comment == '2',
      '#access' => $settings_comment != '0', // Align with action buttons.
      '#title' =>($settings_title_as_name && !$transition->isExecuted())
        ?$this-> t('Change @name state', ['@name' => $workflow->label()])
        : $this->t('Target state'),
      '#description' => ($settings_title_as_name && !$transition->isExecuted())
        ?$this->t('A comment to put in the @name state', ['@name' => $workflow->label()])
        : $this->t('A comment to put in the workflow log.'),
      '#default_value' => $transition ? $transition->getComment() : '',
      '#rows' => 2,
    ];

So, both the #title and #description check to see if $setting_title_as_name is configured. Side note, I also change "t()" to "$this->t()".

I haven't tested or had time to create a patch, but if this works, I think the same process should be applied to every aspect of the workflow element.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scottsawyer created an issue. See original summary.

scottsawyer’s picture

EDIT: in my haste, I forgot to fully update the #description, corrected version below:

    // This overrides BaseFieldDefinition. @todo: apply for form and widget.
    $element['comment'] = [
      '#type' => 'textarea',
      '#required' => $settings_comment == '2',
      '#access' => $settings_comment != '0', // Align with action buttons.
      '#title' =>($settings_title_as_name && !$transition->isExecuted())
        ?$this-> t('Change @name state', ['@name' => $workflow->label()])
        : $this->t('Target state'),
      '#description' => ($settings_title_as_name && !$transition->isExecuted())
        ?$this->t('A comment to put in the @name log.', ['@name' => $workflow->label()])
        : $this->t('A comment to put in the workflow log.'),
      '#default_value' => $transition ? $transition->getComment() : '',
      '#rows' => 2,
    ];
johnv’s picture

johnv’s picture

Status: Active » Needs review

Adding a proper patch.

Status: Needs review » Needs work

The last submitted patch, 3: workflow_3020695_3_commentform.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnv’s picture

Title: Workflow comment form should use the configured workflow name » Do not use technical word 'Workflow' on WorkflowTransitionForm
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.4
Status: Needs work » Fixed

I ended up with a slightly simpler solution:

-      '#title' => t('Workflow comment'),
-      '#description' => t('A comment to put in the workflow log.'),
+      '#title' => t('Comment'),
+      '#description' => t('Briefly describe the changes you have made.'),
 

I also did not understand why to add the extra condition: $settings_title_as_name && !$transition->isExecuted())

Thanks.

johnv’s picture

Status: Fixed » Active

  • johnv committed f947624 on 8.x-1.x authored by scottsawyer
    Issue #3020695 by scottsawyer: Do not use technical word 'Workflow' on...
johnv’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.