While rewriting the Icinga Web login form to ipl forms I've encountered a limitation for decorators.
The html in the following code snippets is simplified for better readability.
Wanted
<div class="control-group remember-me-box">
<input value="n" name="rememberme" type="hidden">
<input value="y" name="rememberme" type="checkbox">
<label class="toggle-switch">
<span class="toggle-slider"></span>
</label>
<div class="control-label-group">
<label class="form-element-label">Angemeldet bleiben</label>
</div>
</div>
Expected PHP
This won't work, because the label group would wrap the label and the checkbox itself.
$this->addElement(
'checkbox',
'rememberme',
[
'label' => $this->translate('Stay logged in'),
'decorators' => [
'Checkbox' => new CheckboxDecorator(),
'RenderElement' => new RenderElementDecorator(),
'Label' => new LabelDecorator(),
'LabelGroup' => [
'name' => 'HtmlTag',
'options' => ['tag' => 'div', 'class' => 'control-label-group']
],
'ControlGroup' => [
'name' => 'HtmlTag',
'options' => ['tag' => 'div', 'class' => 'control-group remember-me-box']
],
]
]
);
This would result into this
<div class="control-group remember-me-box">
<div class="control-label-group">
<input value="n" name="rememberme" type="hidden">
<input value="y" name="rememberme" type="checkbox">
<label class="toggle-switch">
<span class="toggle-slider"></span>
</label>
<label class="form-element-label">Angemeldet bleiben</label>
</div>
</div>
Problem description
Because the transformation type wrap does wrap all previous elements it is not possible to add one or multiple standalone elements before a wrapped element.
While rewriting the Icinga Web login form to ipl forms I've encountered a limitation for decorators.
The html in the following code snippets is simplified for better readability.
Wanted
Expected PHP
This won't work, because the label group would wrap the label and the checkbox itself.
This would result into this
Problem description
Because the transformation type
wrapdoes wrap all previous elements it is not possible to add one or multiple standalone elements before a wrapped element.