Skip to content

[5.x]: Not conditions don't work until checkbox field has been modified #18988

@ryansupercool

Description

@ryansupercool

What happened?

Description

Not conditions aren't working until a checkbox field value has been modified.

Steps to reproduce

  1. Create a checkbox field with two options, all unchecked by default.
  2. Assign field to an entry type/section.
  3. Create a new entry and save. Don't select any checkbox fields.
  4. Using the filters/conditions in the element index (or using a Twig query) create a not one of query. Note behavior.
  5. Within created entry, check an option, and save. The uncheck all options and save.
  6. Do the same query again and not behavior.

Note we are using Twig with craft.entries.section('handle').myField(['not', 'optionA'])

Expected behavior

Newly created entry appears at step 4.

Actual behavior

Newly created entry doesn't appear.

This makes not queries with checkboxes a little brittle and leads to unexpected behavior depending on if a checkbox has other options selected to the one being excluded.

Craft CMS version

5.10.4

PHP version

8.4.20

Operating system and version

No response

Database type and version

MySQL 8.0.40

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions