+
+
+
+ }
+ error={!!(touched && error)}
+ renderValue={selected => (
+
+ {selected
+ .map(item =>
+ choices.find(
+ choice => get(choice, optionValue) === item
+ )
+ )
+ .map(item => (
+
+ ))}
+
+ )}
+ data-testid="selectArray"
+ {...input}
+ value={input.value || []}
+ {...options}
>
-
-
+ {helperText || (touched && error) ? (
+
+
-
- }
- value={this.state.value}
- error={!!(touched && error)}
- renderValue={selected => (
-
- {selected
- .map(item =>
- choices.find(
- choice =>
- get(choice, optionValue) === item
- )
- )
- .map(item => (
-
- ))}
-
- )}
- data-testid="selectArray"
- {...options}
- onChange={this.handleChange}
- >
- {choices.map(this.renderMenuItem)}
-
- {helperText || (touched && error) ? (
-
-
-
- ) : null}
-
- );
- }
-}
+
+ ) : null}
+
+ );
+};
SelectArrayInput.propTypes = {
choices: PropTypes.arrayOf(PropTypes.object),
classes: PropTypes.object,
className: PropTypes.string,
children: PropTypes.node,
- input: PropTypes.object,
- isRequired: PropTypes.bool,
label: PropTypes.string,
- meta: PropTypes.object,
options: PropTypes.object,
optionText: PropTypes.oneOfType([
PropTypes.string,
@@ -274,12 +265,10 @@ SelectArrayInput.propTypes = {
optionValue: PropTypes.string.isRequired,
resource: PropTypes.string,
source: PropTypes.string,
- translate: PropTypes.func.isRequired,
translateChoice: PropTypes.bool,
};
SelectArrayInput.defaultProps = {
- classes: {},
choices: [],
options: {},
optionText: 'name',
@@ -287,10 +276,4 @@ SelectArrayInput.defaultProps = {
translateChoice: true,
};
-const EnhancedSelectArrayInput = compose(
- addField,
- translate,
- withStyles(styles)
-)(SelectArrayInput);
-
-export default EnhancedSelectArrayInput;
+export default SelectArrayInput;
diff --git a/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.js b/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.js
index 4d20fa1b0bc..01ec6dba8cd 100644
--- a/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.js
+++ b/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.js
@@ -1,54 +1,52 @@
import React from 'react';
import expect from 'expect';
import { render, cleanup } from '@testing-library/react';
+import { Form } from 'react-final-form';
+import { TranslationContext } from 'ra-core';
-import { SelectArrayInput } from './SelectArrayInput';
+import SelectArrayInput from './SelectArrayInput';
describe('