Skip to content

Commit

Permalink
Fix multiple select name
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Sep 27, 2020
1 parent 1cd3dd3 commit 516784c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/DefaultTheme/Choice/Choice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ export const Choice = (props) => {
const {
schema = true,
input: {
name,
onChange: onChangeProp,
...input
},
placeholder,
meta,
} = props

const inputName = name + (schema.type === 'array' ? '[]' : '')

return schema.choiceExpanded
? (
<fieldset className="liform-field liform-choice">
Expand All @@ -23,7 +26,7 @@ export const Choice = (props) => {
<label key={i}>
<input
type={schema.type === 'array' ? 'checkbox' : 'radio'}
name={input.name + (schema.type === 'array' ? '[]' : '')}
name={inputName}
value={elValue}
checked={schema.type === 'array' ? input.value.indexOf(elValue) >= 0 : input.value === elValue }
onChange={e => onChangeProp(
Expand All @@ -45,6 +48,7 @@ export const Choice = (props) => {
<Field className="liform-choice" schema={schema} meta={meta}>
<select {...input}
multiple={schema.type === 'array'}
name={inputName}
onChange={e => onChangeProp(extractNativeSelectValue(e))}
onBlur={e => onChangeProp(extractNativeSelectValue(e))}
>
Expand Down

0 comments on commit 516784c

Please sign in to comment.