Add multiple selection support to Select ingredient
What is this pull request for?
This pull request adds support for multiple value selection to the Select ingredient. Content editors can now select multiple options from a dropdown list when the multiple: true setting is enabled in the element definition.
Previously, when content editors needed to select multiple options, they had to either use multiple boolean fields or create workarounds. This enhancement allows a cleaner solution by enabling native multi-select functionality on the existing Select ingredient.
Closes #3398
Notable changes
API Changes:
- Added new
multiplesetting to Select ingredient (defaults tofalsefor backward compatibility) - Values are now serialized as JSON arrays when
multiple: trueis set using ActiveRecord'sserializefeature - Added
multiple?helper method to check if multiple selection is enabled
Behavior Changes:
-
When
multiple: trueis set, the Select ingredient stores an array of values instead of a single string -
Multiple selected values are displayed as a comma-separated list in the frontend
-
The editor renders a multi-select dropdown with individual close buttons (×) for each selected value
Breaking Changes: None - fully backward compatible. Existing Select ingredients without the
multiplesetting continue to work as before.
Usage Example
# config/alchemy/elements.yml
- name: product_filter
ingredients:
- role: categories
type: Select
settings:
multiple: true
select_values:
- electronics
- furniture
- clothing
Checklist
- [X] I have followed Pull Request guidelines
- [X] I have added a detailed description into each commit message
- [X] I have added tests to cover this change
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 97.17%. Comparing base (a004277) to head (9c0cd38).
Additional details and impacted files
@@ Coverage Diff @@
## main #3471 +/- ##
==========================================
+ Coverage 97.16% 97.17% +0.01%
==========================================
Files 285 285
Lines 7466 7478 +12
==========================================
+ Hits 7254 7267 +13
+ Misses 212 211 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@antwertinger some tests are still failing though.
I think this is looking almost good to go, but the git history needs a little bit of love. Would you mind rebasing the PR? I think it can be squashed down to a single commit, as all the changes are related closely.