alchemy_cms icon indicating copy to clipboard operation
alchemy_cms copied to clipboard

Add multiple selection support to Select ingredient

Open antwertinger opened this issue 4 months ago • 3 comments

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 multiple setting to Select ingredient (defaults to false for backward compatibility)
  • Values are now serialized as JSON arrays when multiple: true is set using ActiveRecord's serialize feature
  • Added multiple? helper method to check if multiple selection is enabled

Behavior Changes:

  • When multiple: true is 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 multiple setting 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

antwertinger avatar Nov 06 '25 10:11 antwertinger

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.

codecov[bot] avatar Nov 06 '25 10:11 codecov[bot]

@antwertinger some tests are still failing though.

tvdeyen avatar Nov 06 '25 23:11 tvdeyen

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.

mamhoff avatar Nov 23 '25 22:11 mamhoff