viewfield.module contains the following code intended to suppress rendering a select box when it contains only a single item:

  // If there is only one option, only show arguments.
  if (count($options) === 1 && !$is_field_settings_form) {
    list($key, $label) = each($options);
    $element['vname']['#access'] = FALSE;
    $element['vname']['#default_value'] = $key;
  }

Dynamically changing the interface in this way is a UI anti-pattern that provides no value. This code should be removed.

CommentFileSizeAuthor
#2 viewfield.widget-one-view.1.patch1.22 KBsun

Comments

sun’s picture

At first sight, I wanted to object with:

The superior UI anti-pattern is to expose input fields/widgets that do not allow the user to change or do anything. That's the case here.

...but given the changes in #1221440: Bogus default value in field widget, the widget will now use proper initial '- Select -' and '- None -' default values, so there is actually something to select.

Hence, good point. :)

sun’s picture

Status: Active » Needs review
Issue tags: +D7 stable release blocker
StatusFileSize
new1.22 KB
keithm’s picture

Status: Needs review » Reviewed & tested by the community

This looks good.

sun’s picture

Title: viewfield UI changes entity edit form when single option present » View select in field widget is removed when there is only one option
Status: Reviewed & tested by the community » Fixed

Thanks for reporting, reviewing, and testing! Committed to 7.x-2.x.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

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