Toggle contents of select field to be descending vs ascending.

Created on 1 April 2024, about 1 year ago

Problem/Motivation

We're using BEF in a few places and it's working great but there doesn't seem to be a simple to way to have the contents of a select field (in this case referenced entities) show in descending vs ascending order. Descending would keep the most recent ones near the top, which are the ones we're most likely to interacting with.

✨ Feature request
Status

Active

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States erutan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @erutan
  • Status changed to Closed: works as designed 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States erutan

    Nevermind, this was was a VBO bulk edit option "Always show selection info". :)

  • Status changed to Active 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States erutan
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Postponed: needs info 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Not sure know what you mean "most recent ones near the top"

  • πŸ‡ΊπŸ‡ΈUnited States erutan

    The contents of a select list in BEF are sorted in ascending order, so for sequentially increasing items (think serial numbers, invoices, purchase orders, whatever) the oldest ones are the top of the select. It'd be nice to be able to set them to descending so the more recent ones would be on top.

    0003
    0002
    0001

    etc vs

    0001
    0002
    0003

  • Status changed to Active 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States erutan
  • πŸ‡ΊπŸ‡ΈUnited States gcalex5

    I looked at this a little bit in terms of implementing it for Taxonomy Terms, and I don't think it's feasible. The query to generate Term options for the exposed form seems to occur inside of Core within the valueForm function of:

    • /core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php

    The sort value appears to be hardcoded within Core to "weight." No variables seem to be passed into it besides the Vocabulary ID.

    Trying to manipulate it from hook_query_alter I don't see any variables passed into the Query to indicate that it's coming from any specific View or Filter.

    The only approach that I think would make it possible would be to toss out the options generated from Core and re-query them altogether, which doesn't really make sense from a performance hit point-of-view imo.

  • πŸ‡ΊπŸ‡ΈUnited States erutan

    Thanks for sharing what you found out - while I know you were looking into taxo and don't expect you to develop outside of that itch does it seem this would also be the case for non reference fields?

Production build 0.71.5 2024