Skip to content

Commit

Permalink
changed Select behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
damiano-carradori committed Mar 21, 2019
1 parent d7083ec commit 93ad098
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Form/FormContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class FormContextProvider extends Component {
const { onSubmit } = this.props;

const returnValues = mapObject(values, value => {
if (typeof value !== 'object' || value === null) {
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
return value;
}
if (Object.keys(value).length === 1) {
Expand Down Expand Up @@ -66,6 +66,12 @@ export class FormContextProvider extends Component {
const { files } = target;
content = files;
break;
case 'select':
const { multiple, selectedOptions } = target;
content = multiple ?
[...selectedOptions].map(o => o.value) :
value;
break;
default:
content = value;
}
Expand Down Expand Up @@ -99,6 +105,10 @@ export class FormContextProvider extends Component {
content = value;
}
break;
case 'select':
const { multiple } = ref;
content = multiple ? [] : '';
break;
default:
content = value;
}
Expand Down

0 comments on commit 93ad098

Please sign in to comment.