Skip to content

Conversation

magicsunday
Copy link
Contributor

Currently the Checkbox component cannot be properly used to save empty (unchecked status) settings. A hidden element is missing here, which is assigned the unchecked value.

Copy link

codecov bot commented Dec 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.31%. Comparing base (95621db) to head (86a4fb5).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #4927   +/-   ##
=========================================
  Coverage     35.31%   35.31%           
  Complexity    11406    11406           
=========================================
  Files          1179     1179           
  Lines         47865    47865           
=========================================
  Hits          16905    16905           
  Misses        30960    30960           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Currently the Checkbox component cannot be properly used to save empty (unchecked status) settings. A hidden element is missing here, which is assigned the unchecked value.
@fisharebest
Copy link
Owner

This is how checkboxes have always worked - although I remember being annoyed when I first discovered this.

I am concerned that this change might break existing code that simply checks for the presence of an input, rather than the actual value.

What is the motivation for this change. What would be better/simpler with it?

The current code uses:

  • Validator::boolean('name', false); // returns true for checked and false for unchecked
  • Validator::boolean('name'); // returns true for checked and throws an exception for unchecked

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.

2 participants