Conversation
Make the function `wrapNode` as protected to allow overwriting
|
Thanks for the contribution but could you please share your usecase? This method is |
|
@bwaidelich In some cases the wrapper breaks the layout in the backend. The current behavior destroys the layout by putting a second div between elements where none should be existing. <div data-_neos-form-builder-type="Foo.FormBuilder:Grid" >
<div class="row">
<div data-_neos-form-builder-type="Foo.FormBuilder:Column">
<div class="col col-md-6">
// Content
</div>
</div>
</div>
</div>How it is possible after the change: <div data-_neos-form-builder-type="Foo.FormBuilder:Grid" >
<div class="row">
<div data-_neos-form-builder-type="Foo.FormBuilder:Column" class="col col-md-6">
<div>
// Content, the upper div doesn't have the classes in the backend
</div>
</div>
</div>
</div><?php
namespace Foo\BaseFormBuilder\Fusion;
class FormElementWrappingImplementation extends \Neos\Form\Builder\Fusion\FormElementWrappingImplementation
{
protected function wrapNode(NodeInterface $node, string $output, string $fusionPath): string
{
// [...]
if ($node->getNodeType()->getName() === 'Foo.FormBuilder:Column') {
$columnWidths = '';
if ($node->hasProperty('widthXs')) {
$columnWidthXs = $node->getProperty('widthSm');
$columnWidths .= ($columnWidthXs != 'unset' && $columnWidthXs)
? $node->getProperty('widthXs')
: '';
}
if ($node->hasProperty('widthSm')) {
$columnWidthSm = $node->getProperty('widthSm');
$columnWidths .= ($columnWidthSm != 'unset' && $columnWidthSm)
? ' ' . $node->getProperty('widthSm')
: '';
}
$additionalAttributes['class'] = $columnWidths;
}
return $this->contentElementWrappingService->wrapContentObject($node, $output, $fusionPath, $additionalAttributes);
}
} |
|
Thanks for your thorough explanation. I'm reluctant to make this part of an extensible API because it will most likely break compatibility if the implementation is going to change. If this is just an issue with your specific markup, you could maybe adjust your CSS and/or the rendering of your custom form elements. or, to add custom attributes: does that help? |
|
Ping @erkenes |

Make the function
wrapNodeas protected to allow overwriting