-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Make wrapNode protected #116
base: main
Are you sure you want to change the base?
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
wrapNode
as protected to allow overwriting