Skip to content

Select Field Orders Alphabetically by Default #202

@VargaMate

Description

@VargaMate

Bug Report: Select Field Orders Alphabetically by Default
Describe the Bug:
When adding a select field to a form, the options are automatically ordered alphabetically, which is not always desired. There is no built-in configuration to control the sorting behavior (e.g., asc, desc, or no sorting at all).

$form->select('status_id', __('Status'))
            ->options(\App\Models\Status::all()->pluck('name', 'id'))
            ->default(1);

Even after modifying the Select field at \vendor\open-admin-org\open-admin\src\Form\Field\Select.php by adding:
'shouldSort' => false,

The select options are displayed in the order they are retrieved from the database, which resolves the immediate issue. However, this behavior should ideally be configurable directly in the API, with options for sorting (e.g., asc, desc, or none).

It would be nice to have a configurable sorting feature for the select field that allows developers to choose how options are ordered or disable sorting entirely.

"php": "^8.1",
"laravel/framework": "^10.10",
"open-admin-org/open-admin": "^1.0"

It works for me now, but I wanted to share it with you guys.

Sincerely,
Matthew

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions