Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select Field Orders Alphabetically by Default #202

Open
VargaMate opened this issue Jan 10, 2025 · 0 comments
Open

Select Field Orders Alphabetically by Default #202

VargaMate opened this issue Jan 10, 2025 · 0 comments

Comments

@VargaMate
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant