简体   繁体   中英

How can I control the value of a Field conditionally on redux-form?

I'm trying to set the value of an input Field dynamically according the condition of other variable

I have this checkbox:

const roleWindowCheckbox = ({input, label}) => (
<Checkbox label={label}
        style={{width: '100%', display: 'inline-block'}}
        checked={input.value ? true : false}
        onCheck={input.onChange}
/>);

And I want to set the value of a component to 0 when the input is false

<Field
     format={(value) => numeral(value).format('$0,0.00')}
     normalize={(value) => {FormatTextUtil.formatCurrencyWithMaxDigit(value, 10)}}
     component={TextField}
     hintText='No Limit'
     name='refundVoidLimitField'
     disabled={!this.props.voidRefundEnabled}/>

this.props.voidRefundEnabled is a selector, so that's what I wish to use to change the input value, I tried to return the value on the normalize, but that didn't work, any ideas? The disable is working ok

实际上问题出在字段的格式上,格式使我无法看到结果,但是它可以正常工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM