Problem/Motivation

When the 'Default' formatter is selected, the title of the field is not aligned according to the 'Form Display' settings.
Thisis because the function sets ['#label_display'] hardcoded.

Steps to reproduce

- select 'Default' in 'Form display' with 'in line' label.
- display a node, the field label is not according to the settings.

Proposed resolution

Let the function not set the ['#label_display'], but set it afterwards if needed.
Core code will merge the hardcoded values with configured codes, but will not overwrite the hardcoded values.

Remaining tasks

User interface changes

API changes

In some cases, you need to set the title_display afterwards:

     $widget = workflow_state_formatter($entity, $field_name);
     $widget['#label_display'] = 'before'; // 'above', 'hidden'.

Data model changes

Comments

johnv created an issue. See original summary.

  • johnv committed e0bda88b on 8.x-1.x
    Issue #3519831: Incorrect workflow_state_formatter['#label_display']
    
johnv’s picture

Version: 8.x-1.8 » 2.1.9
Status: Active » Closed (won't fix)

This was only a problem in WorkflowTransitionElement, and is now solved by replacing call to the workflow_state_formatter() with the following code:

   if ($formatter = FALSE) {
      $widget = workflow_state_formatter($entity, $field_name, $from_sid);
      $widget['#title'] = t('Current state');
      $widget['#label_display'] = 'before'; // 'above', 'hidden'.
      $element[$attribute_name]['widget'] = $widget;
      $widget = [];
    }
    else {
      $element[$attribute_name]['widget']['#type'] = 'item'; // Read-only display element.
      $element[$attribute_name]['widget']['#markup'] = WorkflowState::load($from_sid);
      $widget = [];
    }
  

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.