Skip to content

Fix/checkboxlist multiple values#17

Open
skrezh wants to merge 3 commits into
wintercms:mainfrom
skrezh:fix/checkboxlist-multiple-values
Open

Fix/checkboxlist multiple values#17
skrezh wants to merge 3 commits into
wintercms:mainfrom
skrezh:fix/checkboxlist-multiple-values

Conversation

@skrezh

@skrezh skrezh commented May 29, 2026

Copy link
Copy Markdown
Contributor

When a checkboxlist property has multiple values selected (e.g. ["Drinks", "Sauces"]), the filter should allow selecting a single option and show all products where that option is part of the array.

Problem

The checkboxlist property type does not work correctly when multiple values are selected. When a product has several values (e.g., ["Drinks", "Sauces"]), the following issues occur:

  1. PropertyValue::getValueAttribute() returns raw JSON string instead of an array
  2. PropertyValue::getDisplayValueAttribute() displays raw JSON instead of a comma-separated list
  3. PropertyValue::beforeSave() generates an incorrect index_value (slug of the whole JSON string)
  4. UniquePropertyValuesInCategoriesQuery groups by the entire JSON array, so multi-value entries don't appear as separate filter options
  5. ProductEntry::mapProps() / VariantEntry::mapProps() don't split checkboxlist values into individual index entries, breaking JSON_CONTAINS filtering
  6. Property::getValuesForCategory() throws "Cannot access offset of type array" when sorting values
  7. PropertyFields::checkboxlist() passes array to json_decode() causing a TypeError in backend

Changes

  • models/PropertyValue.php: Handle checkboxlist type in getValueAttribute() (return array), getDisplayValueAttribute() (comma-separated string), and beforeSave() (dot-separated slugs as index_value)
  • classes/queries/UniquePropertyValuesInCategoriesQuery.php: Add get() method that expands JSON arrays into individual filter entries
  • classes/index/ProductEntry.php & VariantEntry.php: Split dot-separated index_value into individual array elements in mapProps()
  • models/Property.php: Fix sorting when value is an array
  • formwidgets/PropertyFields.php: Fix json_decode() receiving array instead of string

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.

1 participant