Problem/Motivation

When selecting entities on the modal window, it would be very useful to see how many entities have been selected and how many more may be selected before reaching the limit.

The maximum number of allowed values for a field may be anywhere between 0 and unlimited. However, when the Entity Reference Tree Widget is used, the selection process is "blind" to this. The user only knows the limit has been reached when they can no longer select further entities by clicking them. Additionally when using this widget, the "Add another item" button is not shown on the form, so the user doesn't even know if the field can accept multiple values or not.

Proposed resolution

Change "Selected entities:" at the bottom the modal window to show the number of entities that have already been selected, and the maximum number that may be selected. For example:

"Selected (0 of 1 max): "

"Selected (2 of unlimited): "

"Selected (3 of 3 max): "

I think the word "entities" can be removed so that the line of text is simple and does not become too long. "Entities" is rather a technical word for many non-technical users, and not really necessary or user-friendly.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nick Hope created an issue. See original summary.

Nick Hope’s picture

Patch attached.

It also includes a couple of very minor code cleanups.

It should be possible to apply this to 2.0.0 as well as 8.x-1.x-dev.

Discussion on the exact wording is welcome, as well as opinions on whether this should be a configurable option or not.

Mingsong made their first commit to this issue’s fork.

Mingsong’s picture

Thanks Nick for the brilliant idea.

I just create an PR for it. Once it is tested by others, I am happy to merge it.

  • Mingsong committed bb4ec6b on 8.x-1.x
    Issue #3209106: Display maximum number of allowed values and number...
Mingsong’s picture

Status: Needs review » Fixed

Merged.

Status: Fixed » Closed (fixed)

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

Nick Hope’s picture

Version: 8.x-1.x-dev » 2.x-dev

This change still does not seem to have been committed. It was not in any 8.x-1.x and is not in 2.1.0 or the current 2.x-dev. Patch #2 still applies to those versions.

Can we please re-open the issue?

Mingsong’s picture

The merge request was targeting 8.x-1.x branch. So it was merged into that branch. See the last commits from

https://git.drupalcode.org/project/entity_reference_tree/-/commits/8.x-1.x

Mingsong’s picture

I will create a new merge request for 2.x branch.

Mingsong’s picture