Decorator limitations
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by tracing the decorator transformation type wrap and how it groups prior elements; done means decorators can place standalone elements before a wrapped element while producing the wanted checkbox markup without wrapping all previous elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100