When I create a link field and assign it a label of "link", I expect to see "link" on the entity form. Instead I see only "URL" and "Title." There's discussion in #1801268: Change link field 'title' field to 'link text' of changing those property labels to make them clearer. That will help, but even with clearer property labels, the field label not showing seems like a bug.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Assigned: Unassigned » larowlan
larowlan’s picture

Assigned: larowlan » Unassigned
Status: Active » Needs review
FileSize
1.55 KB
983 bytes

First a test to demonstrate the label is not output.
Then the fix.
I used a details element here, because container does not allow a title.
But perhaps we should refactor container to allow #title - although details is better for a11y.

larowlan’s picture

This is a UX improvement too.
Before
Screen Shot 2013-04-04 at 5.05.37 PM.png

After
Screen Shot 2013-04-04 at 5.05.12 PM.png

Adding some tags to get some input from UX and a11y experts.

andypost’s picture

I think this needs extended test to change cardinality

larowlan’s picture

Good call, extra-test-coverage++

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Yes, that's enough

falcon03’s picture

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

I didn't notice this issue before.

Maybe we should use a fieldset instead of a <details> to wrap the widget form fields.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

@falcon03 Please take a look at #1168246: Freedom For Fieldsets! Long Live The DETAILS.

The scope of the issue to fix a bug, accessibility issue is #1801268: Change link field 'title' field to 'link text'

mgifford’s picture

@andypost - I think that would be semantically better as a fieldset actually. I was quite involved in @sun's campaign for DETAILS.

The move to details was partly a shift for the visual element of having a collapsible fieldset hack that we used in everything prior to D8. There wasn't usually a semantic relationship between the fields.

However with dates, checkboxes, radios and other compound form elements are a group of input fields which are properly organized with a fieldset & legend in order to pass on their relationship to each other.

Related link #504962: Provide a compound form element with accessible labels

larowlan’s picture

Here it is with fieldset instead

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
8.01 KB

Screenshot
Screen Shot 2013-04-06 at 9.22.55 AM.png
Mike - if this is better for a11y (and I like it not being collapsible) - please put back to RTBC.
My first attempt used a fieldset but I thought they were no-go except for radio groups - thanks for clarifying.

andypost’s picture

I'd like to see this collapsible by default. Because better to have ability to free the screen area for complex elements once they do not need changes (node edit for example)

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

I'm pushing it back to RTBC. I'll cycle back about the collapsible piece, but ultimately this is the kind of thing that fieldsets have always been used for.

I don't imagine there's any way to default to having both the URL & Title on on line is there? I'm not sure if that would break some UX pattern. It would of course have to be responsive.

andypost’s picture

But current implementation does not allow the fieldset to be collapsed

larowlan’s picture

I don't think collapsibility is the goal here, adding a label to the field is.
The collapsibility was a by-product of using the details in the first patch - but only because I thought fieldsets were off-limits.
No other fields are collapsible - people can use a fieldgroup contrib module or form_alter if they want to maximise edit space.
Adding '#collapsible' => TRUE is mis-use of the fieldset element in my opinion.
Thoughts?

sreynen’s picture

I agree collapsibility isn't the goal here. Maybe it could be the goal for another issue?

Bojhan’s picture

Issue tags: -Needs usability review

The collapsible part should be discussed in a followup I dont think its needed at this time.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs usability review

Committed c44404a and pushed to 8.x. Thanks!

Bojhan’s picture

Issue tags: -Needs usability review

@alex you had this tab open waay to long :P tnx for commit

klonos’s picture

The collapsible part should be discussed in a followup...

...#1968050: Allow the Link fieldset to be collapsed.

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

YesCT’s picture

Issue summary: View changes
+++ b/core/modules/link/link.module
@@ -176,6 +176,14 @@ function link_field_widget_form(&$form, &$form_state, $field, $instance, $langco
+  // If cardinality is 1, ensure a label is output for the field by wrapping it
+  // in a details element.
+  if ($field['cardinality'] == 1) {

I'm working on another issue, #2416987: Fix UI regression in the menu link form and I wonder why this is cardinality == 1.

I would have thought it would be > 1
or >= 1

why have it in an if at all?

YesCT’s picture

FileSize
187.49 KB

oh, this is why you dont want a fieldset on each when there is more than one.

they are already grouped (so they can be dragged)

:)