Problem/Motivation

Comparator link always show

Steps to reproduce

After disable "Link for entity comparison" field in view modes of commerce product, front-end link never disappeared.
the problem is present in all mode views.

Thank you

CommentFileSizeAuthor
#3 issue-3256180-3.patch1.18 KBmr.york

Comments

trickfun created an issue. See original summary.

lobodakyrylo’s picture

Status: Active » Closed (won't fix)

It's not a bug since the module was designed to show remove link in the first row of the comparison table. If you want to customize the table, you can do it programmatically using hook_entity_comparison_rows_alter, see more in entity_comparison.api.php.

mr.york’s picture

Version: 3.0.1 » 4.0.x-dev
Status: Closed (won't fix) » Needs review
StatusFileSize
new1.18 KB

Fixed the issue.

nagy.balint’s picture

So the issue seems to not be about the comparison table, but the view modes of the entity.

As can be seen in this guide as well https://www.webomelette.com/creating-pseudo-fields-drupal-8 when using the hook_entity_view() for extra fields the $display->getComponent has to be used to make sure that the extra field is only shown when the view mode is configured to show it (see patch in #3)

Without this patch the link to add (or remove) the entity from the comparison list is visible everywhere where the entity is rendered, no matter the view mode, but this couldnt have been intended.

hydra’s picture

Status: Needs review » Reviewed & tested by the community

Yupp, this is indeed a bug - patch works perfectly fine, thank you!

lobodakyrylo’s picture

Status: Reviewed & tested by the community » Fixed
lobodakyrylo’s picture

Status: Fixed » Closed (fixed)