Skip to content

[DX] Allow sorting in all tables rendered via 'theme_table()' #3317

@klonos

Description

@klonos

Describe your issue or idea

While working on #3316 I have tried enabling sorting in the table that lists the fields. I have never done this, so I researched and found some articles around the internet that add sorting functionality to tables. Some examples:

Steps to reproduce (if reporting a bug)

  1. Taking the table in /admin/reports/fields as an example, try to add 'field' => 'something' to each header cell. You can test the sandbox from this dummy PR: TEST/DUMMY PR - DO NOT REVIEW OR MERGE backdrop#2325

Actual behavior (if reporting a bug)

Although adding 'field' => 'something' to the header cells causes the table headers to be rendered as sortable, the actual sorting itself does not work: the page refreshes, the ascending/descending sorting indicator and header color changes, but no sorting happens.

Expected behavior (if reporting a bug)

As a new Backdrop dev, I would expect that sorting should "magically" work in theme_table(), simply by adding 'field' => 'something' to the header cells, no matter what the source of the table cells is (db query, or simple arrays passed).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions