public function LayoutParagraphsBuilder::postRenderComponent in Layout Paragraphs 2.0.x
Filters problematic markup from rendered component.
Parameters
mixed $content: The rendered content.
array $element: The render element array.
Return value
mixed The filtered content.
File
- src/
Element/ LayoutParagraphsBuilder.php, line 401
Class
- LayoutParagraphsBuilder
- Defines a render element for building the Layout Builder UI.
Namespace
Drupal\layout_paragraphs\ElementCode
public function postRenderComponent($content, array $element) {
if (strpos($content, '<form') !== FALSE) {
// Rendering forms within the paragraph preview will break the parent
// form, so we need to strip form tags, "required" attributes,
// "form_token", and "form_id" to prevent the previewed form from
// being processed.
$search = [
'<form',
'</form>',
'required="required"',
'name="form_token"',
'name="form_id"',
];
$replace = [
'<div',
'</div>',
'',
'',
'',
];
$content = str_replace($search, $replace, $content);
}
return $content;
}