react-final-form

How to set/change Field value from external user action 🏁 React Final Form

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 16:30:18
问题 There are many situations in which we might want to set the value of a specific field within a form to help out the user. For example, an online fruit store may ask users how many apples they want to buy. To help users out, we could have 3 buttons such as "minimum" - sets field value to the minimum quantity the store can feasibly sell "maximum" - ditto, but for max "what I bought last time" - sets field value to the quantity of apples the user bought the last time After going over what I

How to set/change Field value from external user action

血红的双手。 提交于 2019-12-03 11:01:26
There are many situations in which we might want to set the value of a specific field within a form to help out the user. For example, an online fruit store may ask users how many apples they want to buy. To help users out, we could have 3 buttons such as "minimum" - sets field value to the minimum quantity the store can feasibly sell "maximum" - ditto, but for max "what I bought last time" - sets field value to the quantity of apples the user bought the last time After going over what I thought were the two most relevant examples ( Loading and Initializing Values and Calculated Fields ), I

Clear a field's value on input clear in react-final-form

泄露秘密 提交于 2019-12-01 21:03:30
I'm using a custom component with react-final-form . On input change it sets the value to the address field. But when the input is cleared it doesn't update the value of the field. So I'm trying to do it with form mutators. I have already added a mutator for clearing the field: mutators={{ clear: ([address], state, { changeValue }) => { changeValue(state, "address", () => undefined); } }} I tried to add it to my custom onChange function, but it doesn't work. onChange={event => props.input.onChange !== undefined ? props.input.onChange({ value: event }) : form.mutators.clear } Or maybe this can