@aarongustafson/form-show-if 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/form-show-if.js +13 -1
- package/package.json +1 -1
package/form-show-if.js
CHANGED
|
@@ -140,7 +140,17 @@ export class FormShowIfElement extends HTMLElement {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
static __getCurrentValue($field) {
|
|
143
|
-
//
|
|
143
|
+
// Single checkbox
|
|
144
|
+
if ($field.type === 'checkbox' && !$field.length) {
|
|
145
|
+
// Only return the value if the checkbox is actually checked
|
|
146
|
+
if ($field.checked) {
|
|
147
|
+
// Return the value, defaulting to "on" if not explicitly set
|
|
148
|
+
return $field.value || 'on';
|
|
149
|
+
}
|
|
150
|
+
return '';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Checkbox array (multiple checkboxes with same name)
|
|
144
154
|
if ($field.length && $field[0].type && $field[0].type == 'checkbox') {
|
|
145
155
|
let value = [];
|
|
146
156
|
let length = $field.length;
|
|
@@ -153,6 +163,8 @@ export class FormShowIfElement extends HTMLElement {
|
|
|
153
163
|
value.reverse();
|
|
154
164
|
return value;
|
|
155
165
|
}
|
|
166
|
+
|
|
167
|
+
// Radio buttons and other inputs
|
|
156
168
|
return $field.value;
|
|
157
169
|
}
|
|
158
170
|
|
package/package.json
CHANGED