Cannot pass formatter to Input
I would like to use formatter and parser function to <Input> or <InputNumber /> components, but can't figure out how to pass those functions.
I've tried adding them to widgetProps, or getValueProps but that didn't seem to work.
Thanks!
For InputNumber you should be able to pass formatter or parser to the component by widgetProps. I don't see them as the API of Input from antd's docs.
Thanks for prompt answer.
Yeah, you're right, there's no formatter or parser for regular Input.
I should probably try to use getValueFromEvent and pass it using fieldProps
You can wrap Input to a new custom component with formatter supported. Like:
const MyInput = props => {
const { value, onChange, formatter, parser } = props;
const newValue = formatter(value);
const newOnChange = value => onChange(parser(value));
const newProps = _.omit(props, ['value', 'onChange', 'formatter', 'parser']);
return <Input {...newProps} value={newValue} onChange={newOnChange} />
}
Great, thanks for the support! I'll give it a try