Problem/Motivation

If using the <label> tag on a #prefix element, such as the Translation sub-heading provided by the content_translation module, the filterAdmin call will sanitize that string.

Proposed resolution

Instead of using #prefix, create a #markup element and move the HTML there.

Remaining tasks

Usability and accessibility testing.

User interface changes

See the after and before screenshots on #1.

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcnventura’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.67 KB

Before:

Before

After:

After

jcnventura’s picture

Title: Add label to filterAdmin » Content translation header in content type edit form is not styled correctly
Issue summary: View changes
Priority: Major » Minor
Issue tags: -Needs security review
FileSize
1.3 KB

Reconsidering it, it makes absolutely no sense to solve the problem by adding label to filterAdmin. Instead, I've decided to move the #title to another element of type #markup, where filterAdmin is not called.

It solves the problem the same way, and it's a lot simpler to get approved.

andrefy’s picture

Status: Needs review » Reviewed & tested by the community

@jcnventura it is working fine for me

xjm’s picture

Priority: Minor » Normal
Status: Reviewed & tested by the community » Needs review
Issue tags: +Accessibility

Thanks @jcnventura and @andrefy! And thanks for the screenshots. I agree the fix in #2 seems more on the right track; the initial patch seems too much out of scope for this one small change.

However, is this change going to affect accessibility? Is the <label> tag correct here at all? If I recall correctly, the way that labels are associated with their elements impacts form accessibility. In normal form elements in Drupal I think we usually do the explicit form (<label for="id">). The label affected by this bug has no association whatsoever for any form element so (as far as I know) it would actually be confusing to some users. And we're moving it even further away from the relevant form element here.

I think the fact that the tag is being stripped is the result of the fact that it's not correct markup in the first place. It should probably be the legend of a fieldset instead, I think. It might be worth looking at other tab content to see how other elements are constructed. E.g., we should probably be using the Form API more correctly, or such.

Setting back to "Needs review" for more discussion.

jcnventura’s picture

The problem is that #title works well as "label for" when used with the checkboxES type, but not with the checkbox type. But you might be right, we should instead fix the checkbox to use title as "label for", which would be consistent with the checkboxes type, and would also link title correctly.

xjm’s picture

Another question -- why do we need the redundant "Translation" and "Enable translation" at all? It seems to me we could just remove the first non-FAPI label. The checkbox is already labeled, and "show language selector" followed by "enable translation" seems easy to understand for me. And in general fewer words improves usability.

mgifford’s picture

Thanks @xjm, you're absolutely right that this would introduce accessibility problems. Better way of providing that visual markup illustrated here #2249089: Improper use of a LABEL for Last Saved & Author

It should be:
'<h4 class="label">' . t('Translation') . '</h4>'

jcnventura’s picture

Or in alternative, like xjm suggested in #6, simply remove the somewhat unnecessary label/header.

mgifford’s picture

True enough @jcnventura - thanks for rolling up @xjm's observation.

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

Marking @jcnventura's patch in #8 RTBC. Tested the patch here /admin/structure/types/manage/article and it looks good.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Less is more. Committed 1d8464b and pushed to 8.0.x. Thanks!

  • alexpott committed 1d8464b on 8.0.x
    Issue #2475231 by jcnventura, mgifford, xjm: Content translation header...

Status: Fixed » Closed (fixed)

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