Problem/Motivation

When I try to use the imagepins TextWidget on a media image, I just get an ajax error.
In the recent log messages I can see that the t() method is not defined.

Error: Call to undefined method Drupal\imagepin\Plugin\imagepin\Widget\TextWidget::t() in Drupal\imagepin\Plugin\imagepin\Widget\TextWidget->formNewElement() (line 28 of drupal/web/modules/contrib/imagepin/src/Plugin/imagepin/Widget/TextWidget.php)

Steps to reproduce

Press the "Pin widgets on this image" button under an image (my image is translatable).
This will just lead to an ajax error instead of opening the modal to create pins.

Proposed resolution

Use the StringTranslationTrait in WidgetBase to make the t() method available for all widgets.

CommentFileSizeAuthor
#2 imagepin-missing-t-method-3214333-0.patch498 bytesguido_s

Comments

Guido_S created an issue. See original summary.

guido_s’s picture

StatusFileSize
new498 bytes

I added the StringTranslationTrait in WidgetBase.php so that the t() method is available for all widgets and doesn't lead to ajax errors anymore.

guido_s’s picture

Status: Active » Needs review
phjou’s picture

Status: Needs review » Reviewed & tested by the community

I got the same issue, the patch works great, thanks.

  • mxh committed 5cc36c8 on 8.x-1.x
    Issue #3214333 by Guido_S, phjou: Missing t() method in Widgets
    
mxh’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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