react-redux-form
react-redux-form copied to clipboard
set array from input value
The Problem
I am not able to set up a custom control which converts a comma separated floats from string to array.
Steps to Reproduce
See codepen link at the bottom for complete example and type "1,2,3" into the input.
<Control.text model="data" mapProps={{
onBlur: ({ model, dispatch }) => {
return event => {
var value = event.target.value.split(',').map(s => parseFloat(s.trim()))
console.log('blur', value)
dispatch(actions.change(model, value))
dispatch(actions.setTouched(model))
}
}
}} />
Expected Behavior
On submit my model should be { data: [1,2,3] }
.
Actual Behavior
Model is {}
.
Reproducible Code Example
https://codepen.io/anon/pen/mLMpwe?editors=0010#0
You must have "model" property on LocalForm and the property path as "model" property of its fields.
Example:
<LocalForm model="person">
<Control.text model="person.name"/>
<Control.text model="person.surname"/>
</LocalForm>