Skip to content

Commit 8c3e0aa

Browse files
committed
Fix #1: Choices for boolean type will now return boolean values
1 parent 8e69a86 commit 8c3e0aa

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/form.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Button from './buttons';
22
import Loader from './loaders';
3-
import {EditorContext, getCsrfCookie} from '../util';
3+
import {EditorContext, getCsrfCookie, capitalize} from '../util';
44

55

66
export function FormInput({label, help_text, error, inputRef, ...props}) {
@@ -53,6 +53,8 @@ export function FormRadioInput({label, help_text, error, value, options, ...prop
5353
inputValue = option.value;
5454
} else {
5555
label = option;
56+
if (typeof label === 'boolean')
57+
label = capitalize(label.toString());
5658
inputValue = option;
5759
}
5860

@@ -80,6 +82,8 @@ export function FormSelectInput({label, help_text, error, value, options, ...pro
8082
inputValue = option.value;
8183
} else {
8284
label = option;
85+
if (typeof label === 'boolean')
86+
label = capitalize(label.toString());
8387
inputValue = option;
8488
}
8589

src/ui.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ function handleChange(e, valueType, callback) {
1818
value = value.trim();
1919
if (value !== '' && !isNaN(Number(value)))
2020
value = Number(value);
21+
} else if (valueType === 'boolean') {
22+
if (value === 'false')
23+
value = false;
24+
else
25+
value = true;
2126
}
2227

2328
callback(e.target.name, value);

0 commit comments

Comments
 (0)