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.
Comment | File | Size | Author |
---|---|---|---|
#2 | Drupal-entity-reference-tree-patch3.png | 33.75 KB | Nick Hope |
#2 | Drupal-entity-reference-tree-patch2.png | 36.69 KB | Nick Hope |
#2 | Drupal-entity-reference-tree-patch1.png | 14.13 KB | Nick Hope |
#2 | entity_reference_tree-show-selected-and-max-3209106-2.patch | 2.07 KB | Nick Hope |
Issue fork entity_reference_tree-3209106
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:
Comments
Comment #2
Nick Hope CreditAttribution: Nick Hope commentedPatch 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.
Comment #5
MingsongThanks Nick for the brilliant idea.
I just create an PR for it. Once it is tested by others, I am happy to merge it.
Comment #7
MingsongMerged.
Comment #9
Nick Hope CreditAttribution: Nick Hope commentedThis 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?
Comment #10
MingsongThe 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
Comment #11
MingsongI will create a new merge request for 2.x branch.
Comment #12
MingsongCommitted into 2.x branch.
https://git.drupalcode.org/project/entity_reference_tree/-/commit/b491e0...