- π¬π§United Kingdom alexpott πͺπΊπ
I've tried to re-create this bug according to the information in the issue summary. I created an entity reference field and used it as a token replacement in a text field that supported tokens - it looked something like
[node:field_test:entity:url]
- this works absolutely fine. The token module is correctly calling toString() on the URL object to get the token value.We need more information with steps to reproduce. It feels that the real problem here is in the token provider not calling ->toString() on URL objects and fixing this in HtmlEscapedText is in the wrong place.
- π¬π§United Kingdom alexpott πͺπΊπ
I also tested this with a link field and
[node:field_link:uri]
works as expected without error. - Status changed to Closed: outdated
over 1 year ago 9:23pm 22 January 2024 - πΊπΈUnited States smustgrave
Since there hasn't been a follow up going to close out as outdated for now. If still a valid bug in D10 please update issue summary with steps to reproduce.
- π¬π·Greece dimitriskr
I got a similar error on my project. I'm trying to find clean reproducible steps. For now, I got it when I tried to render a message entity that had an entity reference field for a view and I used a token
[message:field_view_ref:entity:label]
in the message's text and rendered it programmaticallyError: Object of class Drupal\views\Entity\View could not be converted to string in Drupal\Component\Render\HtmlEscapedText->__construct() (line 31 of core/lib/Drupal/Component/Render/HtmlEscapedText.php).
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('message'); $pre_render = $view_builder->view($message_entity, 'default');