Problem/Motivation

Using CompositeFormElementTrait results in duplicating HTML ids for element and its wrapper. Currently CompositeFormElementTrait is used by #radios and #checkboxes to wrap them into a fieldset.
Potentionaly such behaviour can break js scripts that rely on element's ids.

Steps to reproduce: Create a custom form with #radios/#checkboxes or check any other form that contains any of these types.

Proposed resolution

Add --wrapper suffix to fieldset #id.

Comments

danylevskyi’s picture

Title: Radios form element generates 2 identical CSS ids » Radios form element generates 2 identical HTML ids
Issue summary: View changes
kpv’s picture

Assigned: Unassigned » kpv

It's a common issue for #radios element type with non-empty #title.

kpv’s picture

This bug affects those element types which use CompositeFormElementTrait, currently: radios and checkboxes.
I've attached two patches:

kpv’s picture

Status: Active » Needs review

The last submitted patch, 3: fix-identical-ids-op1-2226323-3.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: fix-identical-ids-op2-2226323-3.patch, failed testing.

The last submitted patch, 3: fix-identical-ids-op1-2226323-3.patch, failed testing.

Status: Needs work » Needs review

The last submitted patch, 3: fix-identical-ids-op1-2226323-3.patch, failed testing.

kpv’s picture

StatusFileSize
new756 bytes

here fieldset id is set directly in CompositeFormElementTrait

Status: Needs review » Needs work

The last submitted patch, 12: fix-identical-ids-op3-2226323-12.patch, failed testing.

kpv’s picture

StatusFileSize
new754 bytes
kpv’s picture

Status: Needs work » Needs review
kpv’s picture

Title: Radios form element generates 2 identical HTML ids » CompositeFormElementTrait causes idential HTML ids for element and its wrapper
Issue summary: View changes
kpv’s picture

Title: CompositeFormElementTrait causes idential HTML ids for element and its wrapper » CompositeFormElementTrait causes identical HTML ids for element and its wrapper

typo

star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This needs test coverage.

kpv’s picture

Issue tags: -Needs tests
StatusFileSize
new1.85 KB

added a test

kpv’s picture

Status: Needs work » Needs review
star-szr’s picture

@kpv awesome, thanks. Can we get a test-only patch uploaded as well so we can see it failing without the bugfix?

kpv’s picture

StatusFileSize
new1.11 KB

Status: Needs review » Needs work

The last submitted patch, 22: fix-identical-ids-2226323-test_only.patch, failed testing.

kpv’s picture

Status: Needs work » Needs review
star-szr’s picture

Status: Needs review » Reviewed & tested by the community

Cool, #19 seems pretty sensible to me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice find. Committed c2ac32c and pushed to 8.0.x. Thanks!

  • alexpott committed c2ac32c on 8.0.x
    Issue #2226323 by kpv | danylevskyi: Fixed CompositeFormElementTrait...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.