feat(core): form reset field utility function #1223
Mergedharry-whorlow(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/1223/headmerged by harry-whorlow(GitHub profile, opens in a new tab) crutchcorn(GitHub profile, opens in a new tab) requested changes
@@ -1957,2 +1960,21 @@19571960 this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')19581961 }1962+1963+ /**1964+ * Resets the field value and meta to default state1965+ */1966+ resetField = <TField extends DeepKeys<TFormData>>(field: TField) => {1967+ this.baseStore.setState((prev) => {1968+ return {1969+ ...prev,1970+ fieldMetaBase: {1971+ ...prev.fieldMetaBase,1972+ [field]: {1973+ isValidating: false,1974+ isTouched: false,1975+ isBlurred: false,1976+ isDirty: false,1977+ isPristine: true,1978+ errors: [],1979+ errorMap: {},1980+ },
Sign in to join this conversation.
View your CI Pipeline Execution ↗ for commit a6133d7adb02439f12cea74bb1190f21440fdf6a.
nx affected --targets=test:sherif,test:knip,tes...nx run-many --target=build --exclude=examples/**☁️ Nx Cloud last updated this comment at
2025-03-11 09:24:13UTC