Problem/Motivation
We are getting the follow errors when render links that are using 'Linkit' format like below. We are using the Linkit attributes sub-module, stable9 as the sub-theme and Drupal 10.1.8.
{% set button = content['#block_content'].field_button.entity.field_link.0|view('linkit') %}
Seems to be the same issue mention here
Array to string conversion in Drupal\Core\Template\AttributeArray->__toString()
π¬
Array to string conversion in Drupal\Core\Template\AttributeArray->__toString()
Fixed
The patch provided does not work.
Warning: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 78 of /app/web/core/lib/Drupal/Core/Template/AttributeArray.php)
#0 /app/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'Array to string...', '/app/web/core/l...', 78)
#1 [internal function]: _drupal_error_handler(2, 'Array to string...', '/app/web/core/l...', 78)
#2 /app/web/core/lib/Drupal/Core/Template/AttributeArray.php(78): implode(' ', Array)
#3 /app/web/core/lib/Drupal/Core/Template/AttributeValueBase.php(53): Drupal\Core\Template\AttributeArray->__toString()
#4 /app/web/core/lib/Drupal/Core/Template/Attribute.php(324): Drupal\Core\Template\AttributeValueBase->render()
#5 /app/web/core/lib/Drupal/Core/Template/TwigExtension.php(562): Drupal\Core\Template\Attribute->__toString()
#6 /app/vendor/twig/twig/src/Environment.php(418) : eval()'d code(45): Drupal\Core\Template\TwigExtension->renderVar(Object(Drupal\Core\Template\Attribute))ject(Drupal\Core\Template\Attribute))
Warning: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 77 of /app/web/core/lib/Drupal/Core/Template/AttributeArray.php)
#0 /app/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'Array to string...', '/app/web/core/l...', 77)
#1 [internal function]: _drupal_error_handler(2, 'Array to string...', '/app/web/core/l...', 77)
#2 /app/web/core/lib/Drupal/Core/Template/AttributeArray.php(77): array_unique(Array)
#3 /app/web/core/lib/Drupal/Core/Template/AttributeValueBase.php(53): Drupal\Core\Template\AttributeArray->__toString()
#4 /app/web/core/lib/Drupal/Core/Template/Attribute.php(324): Drupal\Core\Template\AttributeValueBase->render()
#5 /app/web/core/lib/Drupal/Core/Template/TwigExtension.php(562): Drupal\Core\Template\Attribute->__toString()
#6 /app/vendor/twig/twig/src/Environment.php(418) : eval()'d code(45): Drupal\Core\Template\TwigExtension->renderVar(Object(Drupal\Core\Template\Attribute))
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of /app/web/core/lib/Drupal/Core/Render/Element.php)
#0 /app/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(256, '"0" is an inval...', '/app/web/core/l...', 98)
#1 [internal function]: _drupal_error_handler(256, '"0" is an inval...', '/app/web/core/l...', 98)
#2 /app/web/core/lib/Drupal/Core/Render/Element.php(98): trigger_error('"0" is an inval...', 256)
#3 /app/web/core/lib/Drupal/Core/Render/Renderer.php(404): Drupal\Core\Render\Element::children(Array, true)
#4 /app/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false)
#5 /app/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array)
#6 /app/vendor/twig/twig/src/Environment.php(418) : eval()'d code(67): Drupal\Core\Template\TwigExt