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.
Comment | File | Size | Author |
---|---|---|---|
#3 | workflow_3020695_3_commentform.patch | 1.06 KB | johnv |
Comments
Comment #2
scottsawyerEDIT: in my haste, I forgot to fully update the #description, corrected version below:
Comment #3
johnvComment #4
johnvAdding a proper patch.
Comment #6
johnvComment #7
johnvI ended up with a slightly simpler solution:
I also did not understand why to add the extra condition:
$settings_title_as_name && !$transition->isExecuted())
Thanks.
Comment #8
johnvComment #10
johnv