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

Add collection support for belongs_to fields #230

Merged
merged 6 commits into from
Nov 21, 2024

Conversation

kaka-ruto
Copy link
Contributor

@kaka-ruto kaka-ruto commented Nov 20, 2024

Fixes #156 & #176

Currently, belongs_to fields don't show all available options in the dropdown. This PR:

  • Updates BelongsTo field to support a collection option for loading all available records
  • Updates import map packages to use ga.jspm.io, unpkg did not have tom-select and, from the second issue, tailwind-css-stimulus-components as well

Example usage:

class ArticleResource < Madmin::Resource
  attribute :parent_article, collection: -> { Article.all }
end

Before: Static select dropdown with only the current selection visible
After: Searchable dropdown showing all available options with filtering

Testing:
1. Visit any resource edit page with a belongs_to association
2. Verify the dropdown shows all available options when collection is specified
3. The collection is searchable

Screenshot 2024-11-20 at 16 51 28

@excid3 excid3 linked an issue Nov 21, 2024 that may be closed by this pull request
@excid3 excid3 merged commit 23949f9 into excid3:main Nov 21, 2024
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

Successfully merging this pull request may close these issues.

[email protected] is missing in unpkg Selecting associated models
2 participants