@@ -2,7 +2,7 @@ import {getBlankData} from './data';
22import { Button , FormInput , FormCheckInput , FormRadioInput , FormSelectInput ,
33 FormFileInput , FormRow , FormGroup , GroupTitle , FormRowControls , FormTextareaInput ,
44 FormDateTimeInput , FormMultiSelectInput , FileUploader } from './components' ;
5- import { getVerboseName } from './util' ;
5+ import { getVerboseName , convertType } from './util' ;
66
77
88function handleChange ( e , fieldType , callback ) {
@@ -15,17 +15,10 @@ function handleChange(e, fieldType, callback) {
1515 value = e . target . value ;
1616 }
1717
18- if ( fieldType === 'number' || fieldType === 'integer' ) {
19- value = value . trim ( ) ;
20- if ( value === '' )
21- value = null ;
22- else if ( ! isNaN ( Number ( value ) ) )
23- value = Number ( value ) ;
24- } else if ( fieldType === 'boolean' ) {
25- if ( value === 'false' || value === false )
26- value = false ;
27- else
28- value = true ;
18+ if ( Array . isArray ( value ) ) { /* multiselect widget values are arrays */
19+ value = value . map ( ( item ) => convertType ( item , fieldType ) ) ;
20+ } else {
21+ value = convertType ( value , fieldType ) ;
2922 }
3023
3124 callback ( e . target . name , value ) ;
@@ -108,6 +101,7 @@ function FormField(props) {
108101 InputField = FormSelectInput ;
109102 break ;
110103 case 'multiselect' :
104+ inputProps . valueType = props . schema . type ;
111105 InputField = FormMultiSelectInput ;
112106 break ;
113107 case 'textarea' :
0 commit comments