form
form copied to clipboard
New API - resetField('fieldName')
Discussed in https://github.com/TanStack/form/discussions/1159
Originally posted by wilson12365 February 19, 2025 right now the only way to handle reset a field based on other actions of the form is the following
listeners={{
onChange: ({value}) => {
const defaultMeta = {
isValidating: false,
isTouched: false,
isBlurred: false,
isDirty: false,
errorMap: {}
}
if (value === ‘personal’) {
setFieldValue(‘businessName’, ‘’)
setFieldValue(‘businessLabel’, ‘’)
setFieldMeta(’businessName’, defaultMeta)
setFieldMeta(’businessLabel’, defaultMeta)
}
}}
@crutchcorn has suggested to add resetField('fieldName')