Redux-form-material-ui: [Next] Select Field "Multiple" property doesn't work properly

Created on 26 Dec 2017  路  7Comments  路  Source: erikras/redux-form-material-ui

I may be doing something wrong, but I don't believe so. Rendering a Select field with the Multiple property gives me the following error:

Material-UI: the value property must be an array when using the Select component with multiple.

This is talking about the value property on the component itself, I believe, and not the MenuItem, so not a whole lot I can show on my end. Based on that alone it seems like the redux-form is passing in a raw value instead of an array of values when faced with the multiple property. If you can lead me in the right direction on how to fix it, I'll definitely make a PR.

If you can look at this tonight, it would be unbelievably appreciated. If not, totally understood. Cheers m8!

<Field name="fields" component={Select} multiple fullWidth placeholder="Select your Fields" label="Fields to Compare or Display">
          {this.props.survey.items.map((item) =>
            { return item.type === 'Number' ? (
              <MenuItem value={item.identifier}> 
                <ListItemIcon>
                  <ImportContactsIcon />
                </ListItemIcon>
                {item.label}
              </MenuItem> )
              : null
            }
          )}
        </Field>

Most helpful comment

actually sorry it works with minor change

format={value => Array.isArray(value) ? value : []}

All 7 comments

Having the same issue

Hi @RSpicer

Thank you for reporting issue. So value is being actually passed from what consumer component has passed.

As an example I have added a Unit test case which demonstrate Select with multiple Option.

https://github.com/erikras/redux-form-material-ui/blob/b18ab7267a2d43488f7e11e21bd76dedd34381fd/src/__tests__/Select.spec.js#L34-L53

Could you take a look at it and let me know ?

Please correct me if I have mis understood your question.

+1

I've solved this issue with the following code:

<Field component={Select} multiple format={value => value || []}...

same here, fix above doesn't help

actually sorry it works with minor change

format={value => Array.isArray(value) ? value : []}

Closing this, due to inactivity. Feel free to reopen if issue still persist.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jampy picture jampy  路  6Comments

aaj picture aaj  路  5Comments

klane11 picture klane11  路  7Comments

aludvigsen picture aludvigsen  路  4Comments

aislanmaia picture aislanmaia  路  6Comments