Not sure who's issue this should be logged under so if it is the wrong place please tell me so i can create an issue with the other module.
I enabled custom_search module and as soon as I placed it in any of my regions I got the following error and the page never finished rendering.
The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\Component\Render\HtmlEscapedText::render() in bootstrap_barrio_preprocess_form_element() (line 284 of themes/bootstrap_barrio/bootstrap_barrio.theme).
bootstrap_barrio_preprocess_form_element(Array, 'form_element', Array)
Drupal\Core\Theme\ThemeManager->render('form_element', Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_4c69e5991f3e160b935047dfe4777706db635ab67265fa6f4ec5c39794e17709->block_content(Array, Array)
Twig_Template->displayBlock('content', Array, Array)
__TwigTemplate_4c69e5991f3e160b935047dfe4777706db635ab67265fa6f4ec5c39794e17709->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('themes/bootstrap_barrio/templates/block/block.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render('block', Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_4eda0ce75fcd4d7c7bfea8acfbaae4f24ee45e1495f6c6cfc1fc2dfc1d49ff2b->block_head(Array, Array)
Twig_Template->displayBlock('head', Array, Array)
__TwigTemplate_4eda0ce75fcd4d7c7bfea8acfbaae4f24ee45e1495f6c6cfc1fc2dfc1d49ff2b->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('themes/bootstrap_barrio/templates/layout/page.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render('page', Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_df05244faca2f5ca5a1365e71348b8af3ab67d4d2e64686c649ed6460e498bf3->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('themes/bootstrap_barrio/templates/layout/html.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render('html', Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
I changed settings inside the block and also moved it into different regions but nothing worked it completly crashed the site.
Here is what was actually rendered in HTML:
<body class="layout-one-sidebar layout-sidebar-first user-logged-in path-frontpage">
<head-placeholder token="DP7vUi2cXl_-HSiDUfdYcEIots0uBdyDQrgPJmjmb2VkF6ax-naM1g872Oa_e3-eYDVvRnSnmQ">
<title></title>
<css-placeholder token="DP7vUi2cXl_-HSiDUfdYcEIots0uBdyDQrgPJmjmb2VkF6ax-naM1g872Oa_e3-eYDVvRnSnmQ">
<js-placeholder token="DP7vUi2cXl_-HSiDUfdYcEIots0uBdyDQrgPJmjmb2VkF6ax-naM1g872Oa_e3-eYDVvRnSnmQ">
<a class="visually-hidden focusable skip-link" href="#main-content"> Skip to main content </a>
<div id="toolbar-administration" class="toolbar" aria-label="Site administration toolbar" role="group">
<nav id="toolbar-bar" class="toolbar-bar clearfix" aria-label="Toolbar items" role="navigation">
<h2 class="visually-hidden">Toolbar items</h2>
<div class="hidden home-toolbar-tab toolbar-tab">
<div class="toolbar-tab">
<div class="toolbar-tab">
<div class="hidden contextual-toolbar-tab toolbar-tab">
<div class="toolbar-tab">
</nav>
</div>
<div id="page-wrapper">
<div id="page">
<header id="header" class="header" aria-label="Site header" role="banner">
<nav id="navbar-top" class="navbar navbar-light bg-primary">
<div class="section container-fluid clearfix">
<div class="navbar-nav">
<div id="block-customsearchform" class="custom-search-block-form contextual-region block block-custom-search" aria-describedby="custom-search-form" data-drupal-selector="custom-search-block-form" role="search">
<h2 id="custom-search-form">Custom Search form</h2>
<div data-contextual-id="block:block=customsearchform:langcode=en"></div>
<div class="container-inline content">
The website encountered an unexpected error. Please try again later.
<br>
<em class="placeholder">Error</em>
: Call to undefined method Drupal\Component\Render\HtmlEscapedText::render() in
<em class="placeholder">bootstrap_barrio_preprocess_form_element()</em>
(line
<em class="placeholder">284</em>
of
<em class="placeholder">themes/bootstrap_barrio/bootstrap_barrio.theme</em>
).
<pre class="backtrace">bootstrap_barrio_preprocess_form_element(Array, 'form_element', Array) Drupal\Core\Theme\ThemeManager->render('form_element', Array) Drupal\Core\Render\Renderer->doRender(Array) Drupal\Core\Render\Renderer->doRender(Array, ) Drupal\Core\Render\Renderer->render(Array) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) __TwigTemplate_4c69e5991f3e160b935047dfe4777706db635ab67265fa6f4ec5c39794e17709->block_content(Array, Array) Twig_Template->displayBlock('content', Array, Array) __TwigTemplate_4c69e5991f3e160b935047dfe4777706db635ab67265fa6f4ec5c39794e17709->doDisplay(Array, Array) Twig_Template->displayWithErrorHandling(Array, Array) Twig_Template->display(Array) Twig_Template->render(Array) twig_render_template('themes/bootstrap_barrio/templates/block/block.html.twig', Array) Drupal\Core\Theme\ThemeManager->render('block', Array) Drupal\Core\Render\Renderer->doRender(Array) Drupal\Core\Render\Renderer->doRender(Array, ) Drupal\Core\Render\Renderer->render(Array) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) __TwigTemplate_4eda0ce75fcd4d7c7bfea8acfbaae4f24ee45e1495f6c6cfc1fc2dfc1d49ff2b->block_head(Array, Array) Twig_Template->displayBlock('head', Array, Array) __TwigTemplate_4eda0ce75fcd4d7c7bfea8acfbaae4f24ee45e1495f6c6cfc1fc2dfc1d49ff2b->doDisplay(Array, Array) Twig_Template->displayWithErrorHandling(Array, Array) Twig_Template->display(Array) Twig_Template->render(Array) twig_render_template('themes/bootstrap_barrio/templates/layout/page.html.twig', Array) Drupal\Core\Theme\ThemeManager->render('page', Array) Drupal\Core\Render\Renderer->doRender(Array, ) Drupal\Core\Render\Renderer->render(Array) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) __TwigTemplate_df05244faca2f5ca5a1365e71348b8af3ab67d4d2e64686c649ed6460e498bf3->doDisplay(Array, Array) Twig_Template->displayWithErrorHandling(Array, Array) Twig_Template->display(Array) Twig_Template->render(Array) twig_render_template('themes/bootstrap_barrio/templates/layout/html.html.twig', Array) Drupal\Core\Theme\ThemeManager->render('html', Array) Drupal\Core\Render\Renderer->doRender(Array, ) Drupal\Core\Render\Renderer->render(Array) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) Stack\StackedHttpKernel->handle(Object, 1, 1) Drupal\Core\DrupalKernel->handle(Object) </pre>
</div>
</div>
</div>
</div>
</nav>
</header>
</div>
</div>
</js-placeholder>
</css-placeholder>
</head-placeholder>
</body>
I hope this make sense and I have created an issue in the right place.
Comments
Comment #2
staulien commentedComment #3
hatuhay commentedThe way custom_search is altering the confirm conflicts with this function:
For some reason the
render()function is not declared on$variables['label']['#title'].Please with this explanation open a issue on custom_search module, linking with this one.
Let me know any updates.
Comment #4
hatuhay commentedComment #5
staulien commentedI have created an issue with the maintainer of the module. ISSUE LINK
Thanks for you very quick resonse and solution!
Comment #6
mario steinitzWe're maintaining the custom_search module and found the checkboxes and radios are not rendered properly with the bootstrap_barrio theme. Therefore we adapted our local test version of the bootstrap_barrio theme to letting it render the checkbox and radio label within the form_element template, not the form label template (basically an adapted version of the label pre-process function integrated within the form element pre-processing):
bootstrap_barrio.theme:
templates/form/form-element.html.twig:
I did not attach a patch file. But the above code should get it working.
Comment #8
hatuhay commentedThanks Mario,
Add he end the solution was simple:
Comment #9
mario steinitzYour above solution may work to show the label texts, but it leaves the rendered label tag of your form element template without context-related attributes (as 'class', 'for' or 'id').
The label won't be pre-processed by form.inc's template_preprocess_form_element_label() and your template also does not take any additional label attributes into account.
A good example where this would be required is a custom module of ours that replaces the browsers' standard checkboxes and radios using CSS by adding according classes to the wrapping labels within a form pre-processing.
Therefore we decided for this longer version I posted above.
Additionally, during our tests we found that the label property of the form_element variables may be an object as well that does not have the render() method. (I can't tell for sure which object it was. There are no notes on that.) Therefore the
if (is_object($variables['label']['#title']) && method_exists($variables['label']['#title'], 'render')) { [...] }in our example.
Comment #10
hatuhay commentedOK
Got the idea, bootstrap_barrio is missing the label preprocess and it is not processing the label object.
Good I will use your long version as it seems to be the right way.
Thanks!!
Comment #11
hatuhay commentedComment #12
toomanynights commentedHi there,
I'm sorry for reopening, but is this indeed fixed?
Custom Search module still doesn't work with Barrio..
Comment #13
hatuhay commented