You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If any of those checkboxes is changed to checked and saved once then the next time you save the form and you uncheck them the cart/order values will still be true/1. The unchecked checkboxes are not sent in the request which is standard in html forms, but the actionUpdateCart() is not updating this fields.
Steps to reproduce
Create a custom field of type Lightswitch
Add field to the template as an input of type checkbox
Save the form first with the checkbox checked
Remove the item from the cart and go back to the same form
Uncheck the checkbox and save
Expected behavior
The value for the field should be false/0 (cart.booleanField == 0) after you uncheck the checkbox and save the form.
Actual behavior
The value of the field is true/1 (cart.booleanField == 1) even after saving the form with the checkbox unchecked.
This is expected behaviour with HTML checkboxes. If they aren't clicked then the data is not submitted to the server. This is not a Craft CMS/Commerce behaviour but the normal HTML checkbox behaviour.
You would need to have a hidden input with the same name before the normal checkbox submitting a false value if you want a false submitted.
What happened?
Description
We have some custom fields of type
Lightswitch
and show them in the booking template as checkboxes:If any of those checkboxes is changed to checked and saved once then the next time you save the form and you uncheck them the cart/order values will still be
true/1
. The unchecked checkboxes are not sent in the request which is standard in html forms, but theactionUpdateCart()
is not updating this fields.Steps to reproduce
Lightswitch
Expected behavior
The value for the field should be
false/0
(cart.booleanField == 0
) after you uncheck the checkbox and save the form.Actual behavior
The value of the field is
true/1
(cart.booleanField == 1
) even after saving the form with the checkbox unchecked.Craft CMS version
4.4.15
Craft Commerce version
4.2.11
PHP version
8.1.16
Operating system and version
Debian
Database type and version
MariaDB 10.4.28
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: