Skip to content

Conversation

@i-just
Copy link
Contributor

@i-just i-just commented Aug 22, 2025

Description

When querying the multi-options field (checkboxes or multi-select), account for querying by ':empty:' and ':notempty:' values.
When column type is JSON, the empty value can be stored as null, empty string, or empty array (`'[]``).

Steps to reproduce:

  • create one of each: checkboxes, radio, multi-select, dropdown field; each with options “a”, “b”, “c”
  • create a section with an entry type that has all those fields
  • create the following entries in that section:
    • “test 1” => all fields are empty
    • “test 2” => fill out checkboxes and multi-select with options: “a”, “b”
    • “test 3” => fill out the radio and dropdown with the option “a”
    • “test 4” => fill out checkboxes and multi-select with options: “a”, “c” and radio and dropdown with the option “b”

Filter the element index table by each field (one at a time) and test that “is empty” and “is not empty” work as expected.

Set up a template that queries by multiple values where one of them is ':empty:' or ':notempty:'. For example:

<h3>multi select</h3>
{% set entries = craft.entries.section('oli').myMultiSelect(['b',':empty:']).orderBy('title').all() %}
{% for entry in entries %}
    <p>{{ entry.title }}</p>
{% endfor %}
<hr />

<h3>checkboxes</h3>
{% set entries = craft.entries.section('oli').myCheckboxes(['b', ':empty:']).orderBy('title').all() %}
{% for entry in entries %}
    <p>{{ entry.title }}</p>
{% endfor %}
<hr />

<h3>dropdown</h3>
{% set entries = craft.entries.section('oli').myDropdown(['b', ':empty:']).orderBy('title').all() %}
{% for entry in entries %}
    <p>{{ entry.title }}</p>
{% endfor %}
<hr />

<h3>radio</h3>
{% set entries = craft.entries.section('oli').myRadio(['b', ':empty:']).orderBy('title').all() %}
{% for entry in entries %}
    <p>{{ entry.title }}</p>
{% endfor %}

The result (with this PR):

  • multi select => test 1, test 2, test 3
  • checkboxes => test 1, test 2, test 3
  • dropdown => test 1, test 2, test 4
  • radio => test 1, test 2, test 4

The result without this PR:

  • multi select => test 2
  • checkboxes => test 2
  • dropdown => test 1, test 4
  • radio => test 1, test 2, test 4

Related issues

n/a; reported by @olivierbon

@i-just i-just requested a review from brandonkelly August 22, 2025 08:12
@i-just i-just marked this pull request as draft August 22, 2025 14:33
@i-just
Copy link
Contributor Author

i-just commented Aug 22, 2025

I had to put it back into draft as the second commit is causing other issues.

@i-just i-just marked this pull request as ready for review August 26, 2025 12:37
@brandonkelly brandonkelly merged commit 3794f02 into 5.x Oct 21, 2025
6 checks passed
@brandonkelly brandonkelly deleted the bugfix/multi-options-field-and-empty-notempty-querying branch October 21, 2025 19:01
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.

3 participants