Problem/Motivation

Column classes are not inserted to Twig template, only the word "Array."

Steps to reproduce

Install BLB with Bootrap Barrio

As a result, the column div tags do not have the necessary column classes for layout. Please see attached screenshot.

Here is a PHP notice displayed with the page on our development server.

Notice: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 78 of core/lib/Drupal/Core/Template/AttributeArray.php).
Drupal\Core\Template\AttributeArray->__toString() (Line: 53)
Drupal\Core\Template\AttributeValueBase->render() (Line: 324)
Drupal\Core\Template\Attribute->__toString() (Line: 67)
__TwigTemplate_de647c1a6fa8093afb3e76c34d4f662a89ae1b3c64a1d292dde368922e9fd3da->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('modules/contrib/bootstrap_layout_builder/templates/blb-section.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('blb_section', Array) (Line: 422)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 107)
__TwigTemplate_62a6282e682281f06d245201239faaf8a2e8ef041aeeab9f5c50bb691ae16e44->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/contrib/bootstrap_barrio/templates/content/node.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 422)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

ianchan created an issue. See original summary.

Christopher Riley’s picture

I am seeing the same issue. Any idea on what we can do to get this rectified?

Warning: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 77 of core/lib/Drupal/Core/Template/AttributeArray.php).

Drupal\Core\Template\AttributeArray->__toString() (Line: 53)
Drupal\Core\Template\AttributeValueBase->render() (Line: 324)
Drupal\Core\Template\Attribute->__toString() (Line: 67)
__TwigTemplate_1ba1f19c738d22c3be2d0f534d017b73->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('modules/contrib/bootstrap_layout_builder/templates/blb-section.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('blb_section', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 164)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 707)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Christopher Riley’s picture

I have tracked down the offending line of twig code, in the blb-section.html.twig file the line:

Is the one that is causing the issue. Now I just need to figure out how to fix it. Any suggestions are greatly appreciated.

Christopher Riley’s picture

I was using dev and not release. I do not see the issue on the release version.

Christopher Riley’s picture

Not wanting to beat a dead horse, however I have found no reference anywhere that shows that in the dev version that the following line will work:

The only references I can find are those such as:

Etc. If we are only wanting to add the class blb_region_col_whatever wouldn't a regular attributes add class work?

Suggestions?

Christopher Riley’s picture

Can anyone buy me a clue on this one? I am using 3.0 dev version, and the offending line is

within the blb-section.html.twig.

There is no reason that we should have

where it should be in my instance for example
. I really think that this needs to be looked at and corrected for proper formatting but I am at a loss as to the best way to correct it.

Thanks in advance.

smustgrave’s picture

Can confirm I'm seeing this issue now too just randomly .

grabby’s picture

I am also seeing this after upgrading to 2.1.0 from 2.0.1.

ilfelice’s picture

Howdy,

Been successfully using this great module in combination with a Bootstrap 3 sub-theme.

Today, I updated the module from 2.0.1 to 2.1.0, and I started seeing the same problem described here.

I have not been able to find a solution so far, so I had to downgrade to 2.0.1 for now.

plessas’s picture

StatusFileSize
new15.59 KB

As a temporary solution, I configured the column classes for each section from the UI as shown in the attached screenshot. For example, I had a section with three columns each one having the class 'col-lg-4 col-md-4 col-12'. Adding the class 'col-lg-4 col-md-4 col-12' from the UI results in:

<div class="Array col-lg-4 col-md-4 col-12"></div>
<div class="Array col-lg-4 col-md-4 col-12"></div>
<div class="Array col-lg-4 col-md-4 col-12"></div>

which renders the section correctly.

ilfelice’s picture

@plessas

Thank you for the temporary solution. It can confirm that it does the trick.

mlzr’s picture

Confirm the same problem. After update all page layouts are broken, and in stead of the usual bootstrap code I see this 'Array' code.

Consider #10 as a temporary solution for a small set of pages.

I am not a coder so I am stuck for now... hope there will be a solution soon. I can test if applicable.

mlzr’s picture

So I was searching for a solution, bud can't find...

I update the website with "composer update".
The line for updating this module was: ""require": {
"drupal/bootstrap_layout_builder": "^2.0","

Then the module update to 2.1.0 and this problem is occuring. Then I set "drupal/bootstrap_layout_builder": "2.0"," , so fixed the version to 2.0 and execute composer update. The system is downgrading to 2.0 then I don't have this issue.

After "composer update", all other modules + drupal are up-to-date.
For your info, after the update: Drupal is 9.5.1, the theme is Barrio Bootstrap 5 Theme 5.5.8. PHP 8.1. (and bootstrap_layout_builder is 2.0)

marcom2021’s picture

@plessas @jorgemare

Are you still able to edit sections when you add classes to rows? When I add classes to the rows in a section I can no longer edit the section.
There's an Uncaught Drupal.AjaxError error showing in my browser console.

I'm using Drupal 9.5.1. and the default Bootstrap 5 theme.

jmaerckaert’s picture

Version: 2.0.1 » 2.1.0
StatusFileSize
new945 bytes

This patch fixes the problem for version 2.1.0.

jmaerckaert’s picture

Status: Active » Needs review
smustgrave’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Confirmed the patch #15 fixes the issue.

Updating to critical as the module doesn't work currently.

mahmoud-zayed’s picture

Status: Reviewed & tested by the community » Fixed
mahmoud-zayed’s picture

Status: Fixed » Closed (fixed)

Thank you all, Added to 2.1.1 release.

ilfelice’s picture

@marcom2021

The just released version 2.1.1 fixes the problem described here, and the inability to edit sections that you reported (which I did see later in my test environment).

Thank you @mahmoud-zayed for the prompt response!

mlzr’s picture

@jmaerckaert @mahmoud-zayed
Top! Thanks for the super-rapid-response!

I installed the #2.1.1 and can confirm that the problems are solved.

Thanks, GH Lukassen