Problem/Motivation

When adding a relationship to the content_moderation_state entity in a view, the machine name of the current state displays, rather than the state's label:

Steps to reproduce

  • Add a view of a moderated entity type (eg, Content)
  • Add a relationship to the 'Moderation state'
  • Add the moderation state field* using the relationship

*This is not to be confused with the calculated moderation state field (#2859381: Broken/missing handler for Moderation state field).

Proposed resolution

The Views data should specify the appropriate formatter for this field (I think it's ContentModerationStateFormatter, but am not positive).

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhedstrom created an issue. See original summary.

Sam152’s picture

The formatter assumes it's for the computed field, but could probably be made to work with both. As discussed in #2859381: Broken/missing handler for Moderation state field, we can make the computed field work in views once this bugfix gets in: #2852067: Add support for rendering computed fields to the "field" views field handler

GoZ’s picture

Status: Active » Needs review
FileSize
1.62 KB

Maybe it's not the best way to deal with this (we still have a broken handler), but here is a patch which display label instead of key.

timmillwood’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
mstef’s picture

Works. Thanks.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

amateescu’s picture

Status: Needs work » Closed (outdated)
Issue tags: -Needs tests

In #2902187: Provide a way for users to moderate content, the moderation state views field correctly displays the label of a state instead of its ID, so this must have been fixed somewhere else in the meantime.

sukanya.ramakrishnan’s picture

Status: Closed (outdated) » Needs work

This issue is still there without the patch being applied. As the description says, it happens only when a relationship to content moderation state is added and the field from the relationship is added to the view.

The issue doesnt occur when the moderation state field from the node table is directly used instead of a relationship,
seems like It was fixed here https://www.drupal.org/node/2852067

Sam152’s picture

Status: Needs work » Closed (outdated)

Fixed since #2859381: Broken/missing handler for Moderation state field by using the computed field directly on the entity.