Skip to content

New API - resetField('fieldName') #1177

@crutchcorn

Description

@crutchcorn

Discussed in #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')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions