public function BlockComponentPreviewFormReplace::onBuildRender in Dashboards with Layout Builder 8
Change forms to divs if in layout builder's preview mode.
Parameters
\Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event: The section component render event.
File
- src/
EventSubscriber/ BlockComponentPreviewFormReplace.php, line 64
Class
- BlockComponentPreviewFormReplace
- Replaces form elements with divs in layout builder previews.
Namespace
Drupal\dashboards\EventSubscriberCode
public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
$build = $event
->getBuild();
if ($event
->inPreview() && isset($build['content']) && is_array($build['content'])) {
$build['content'] = $this
->convertFormsToDiv($build['content']);
$event
->setBuild($build);
}
}