Skip to content
Snippets Groups Projects
Commit ae083040 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][TASK] Connect label with element in FormEngine

A single FormEngine element (created by "element"
classes that typically extend AbstractFormElement)
takes care of the "inner" HTML of an element.

The surrounding "outer" HTML like embedding elements
in palettes is created by "container" classes. Also,
<label> tags for single elements are created by
container classes, namely PaletteAndSingleContainer
and FlexFormElementContainer.

The situation having <label> done by a container and
the inner HTML done by elements has drawbacks:
First, "label" tags should have a "for" attribute,
to connect it with input fields having "id" attribute.
This is one of the accessibility "must haves".
Separating label and fields in different classes
does not allow doing this. Secondly, not all elements
have such input or select tags at all. In those cases,
the label is not a label, but should be a legend
embedded in a fieldset.

The patch moves the existing label tag generation from
container classes to element classes: Only elements
know if, how and where label and legend tags should
be placed. The patch adds two helper methods to
AbstractFormElement to simplify this, and connects
the label tag with the input field in all elements
or adds a fieldset with a legend.

The v12 version of the patch needs to jump through
some additional loops: When elements take care of
label or legend, they signal this by setting the
flag labelHasBeenHandled in the result array. The
container then skips label creation to not have
them twice. This is a b/w compat layer for not yet
adapted custom elements in v12. The v13 version of
the patch does not come with this fallback layer
and documents needed custom element changes in a
ReST file.

Resolves: #97330
Releases: main, 12.4
Change-Id: Ia110eef5ec17aa4b7c731c3f82262b932d86958f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79492


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent a28cfa49
Branches
Tags
Showing
with 116 additions and 112 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment