Skip to content

Commit 3d66552

Browse files
committed
Fixes an issue where Lightswitch toggle fields would not work properly on Craft 3.5.18+. Bump to 2.2.4
1 parent a9bd816 commit 3d66552

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 2.2.4 - 2021-01-20
8+
### Fixed
9+
- Fixes an issue where Lightswitch toggle fields would not work properly on Craft 3.5.18+
10+
711
## 2.2.3 - 2020-12-27
812
### Fixed
913
- Fixes Postgres SQL errors

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mmikkel/reasons",
33
"description": "Adds conditionals to field layouts.",
44
"type": "craft-plugin",
5-
"version": "2.2.3",
5+
"version": "2.2.4",
66
"keywords": [
77
"craft",
88
"cms",

src/assetbundles/reasons/dist/js/render.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,12 @@
306306
case 'craft\\fields\\Lightswitch':
307307
$toggleFieldInput = $toggleField.find('.input *:input:first');
308308
if ($toggleFieldInput.length > 0) {
309-
toggleFieldValue = $toggleFieldInput.val() === '1' ? 'true' : 'false';
309+
// Lightswitch markup changed in Craft 3.5.18
310+
if ($toggleFieldInput.is('button')) {
311+
toggleFieldValue = $toggleFieldInput.attr('aria-checked');
312+
} else if ($toggleFieldInput.is('input')) {
313+
toggleFieldValue = $toggleFieldInput.val() === '1' ? 'true' : 'false';
314+
}
310315
}
311316
break;
312317
case 'craft\\fields\\Checkboxes':

0 commit comments

Comments
 (0)