Problem/Motivation

When adding / configuring an entity reference field, the selection config options expose a "Sort by" whose purpose / meaning is not very intuitive:

Proposed resolution

Improve the wording and/or add a description for that setting.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

marcoscano created an issue. See original summary.

marcoscano’s picture

Status: Active » Needs review
StatusFileSize
new794 bytes
new16.86 KB

First shot.

sort by description 1st shot

jwkovell’s picture

Patch works as advertised!

Would this slightly shorter description still be sufficiently descriptive?
"Select the field to be used to sort entity options."

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

alison’s picture

Issue tags: +Needs reroll
alison’s picture

(Needed reroll for 8.9.x because of #3089523: Use progressive disclosure to hide Sort options on entity reference fields until bundles are selected; please note: old version of patch still works on 8.8.x, until if/when #3089523 is backported!)

Attached: reroll for 8.9.x, and a plain diff of old/new versions of patch.

Coming up next: There's a little spelling typo ("refrenced"), but also, I agree that the language can be tightened just a bit, as @jwkovell mentioned in #3! Anyway, that'll be the next file -- wanted the reroll to have its own patch version so things don't get too confusing.

alison’s picture

StatusFileSize
new788 bytes
new783 bytes
new779 bytes

Mkay, revised language idea attached -- not much shorter haha, I went back and forth... (Also attached, an corresponding version for 8.8.x, based on #2.)

I *think* this version is clearer, but if folks prefer the original language, I can do a version that just fixes the typo and nothing else, just to help wrap things up!

alison’s picture

jhodgdon’s picture

Hm.

Adding a description to this field is definitely a good idea, in my opinion.

I'm not sure about the wording though. It brings up questions, like:
- Is this sort order followed for all widgets? (autocomplete, select, checkboxes, ...)
- Why isn't it an option on the widget anyway? It seems to be only relevant for the editing form, not for the field settings, so I don't actually understand why it is on the field settings in the first place.
- Is this option available when you select a View to determine the available entities, and if so, does it override the sort in the view?

And the proposed wording:
Select a field to use for sorting available entity options.

- Maybe get rid of "available"? I don't think that really adds anything to the description.
- Technically, it's not really just fields that are options here. For fields that have more than one attribute/value, such Image fields, you have the option to sort by each attribute, not to sort by the "field" as a whole (which wouldn't really make sense for an Image field anyway).
- I wonder why we don't choose a sensible default, which would be the label/title? I am pretty sure that is what would be shown to the user in lists of entity options, so it seems only sensible to default to putting what is shown in alphabetical order.

I realize that these questions probably go beyond the scope of this issue, but ... those are what occur to me when I look at this.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

abhijith s’s picture

Patch failed to apply on 9.2.x.Needs reroll

Checking patch core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php...
error: while searching for:
      $form['sort']['field'] = [
        '#type' => 'select',
        '#title' => $this->t('Sort by'),
        '#options' => [
          '_none' => $this->t('- None -'),
        ] + $fields,

error: patch failed: core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php:145
error: core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php: patch does not apply
chris matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
abhijith s’s picture

StatusFileSize
new784 bytes

Rerolled patch #8.Please check it

abhijith s’s picture

Status: Needs work » Needs review
chris matthews’s picture

Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 17: 2927819-reroll-16.patch, failed testing. View results

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.