Icinga / Icinga/ipl-html

Decorator limitations

Open
#180 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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>
Image

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>
Image

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.