Defined in: packages/form-core/src/FieldApi.ts:427
A class representing the API for managing a form field.
Normally, you will not need to create a new FieldApi instance directly. Instead, you will use a framework hook/function like useField or createField to create a new instance for you that uses your framework's reactivity model. However, if you need to create a new instance manually, you can do so by calling the new FieldApi constructor.
• TParentData
• TName extends DeepKeys<TParentData>
• TFieldValidator extends | Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined
• TFormValidator extends Validator<TParentData, unknown> | undefined = undefined
• TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>
new FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>(opts): FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>
new FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>(opts): FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>
Defined in: packages/form-core/src/FieldApi.ts:477
Initializes a new FieldApi instance.
FieldApiOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>
FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>
form: FormApi<TParentData, TFormValidator>;
form: FormApi<TParentData, TFormValidator>;
Defined in: packages/form-core/src/FieldApi.ts:441
A reference to the form API instance.
name: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple<TParentData> ? PrefixTupleAccessor<TParentData<TParentData>, AllowedIndexes<TParentData<TParentData>, never>, []> : TParentData extends any[] ? PrefixArrayAccessor<TParentData<TParentData>, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor<TParentData<TParentData>, []> : TParentData extends string | number | bigint | boolean ? "" : never;
name: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple<TParentData> ? PrefixTupleAccessor<TParentData<TParentData>, AllowedIndexes<TParentData<TParentData>, never>, []> : TParentData extends any[] ? PrefixArrayAccessor<TParentData<TParentData>, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor<TParentData<TParentData>, []> : TParentData extends string | number | bigint | boolean ? "" : never;
Defined in: packages/form-core/src/FieldApi.ts:451
The field name.
options: FieldApiOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>;
options: FieldApiOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>;
Defined in: packages/form-core/src/FieldApi.ts:455
The field options.
store: Derived<FieldState<TData>>;
store: Derived<FieldState<TData>>;
Defined in: packages/form-core/src/FieldApi.ts:465
The field state store.
timeoutIds: Record<ValidationCause, null | Timeout>;
timeoutIds: Record<ValidationCause, null | Timeout>;
Defined in: packages/form-core/src/FieldApi.ts:472
get state(): FieldState<TData>
get state(): FieldState<TData>
Defined in: packages/form-core/src/FieldApi.ts:469
The current field state.
FieldState<TData>
getInfo(): FieldInfo<TParentData, TFormValidator>
getInfo(): FieldInfo<TParentData, TFormValidator>
Defined in: packages/form-core/src/FieldApi.ts:673
Gets the field information object.
FieldInfo<TParentData, TFormValidator>
getMeta(): FieldMeta
getMeta(): FieldMeta
Defined in: packages/form-core/src/FieldApi.ts:662
getValue(): TData
getValue(): TData
Defined in: packages/form-core/src/FieldApi.ts:644
Gets the current field value.
TData
Use field.state.value instead.
handleBlur(): void
handleBlur(): void
Defined in: packages/form-core/src/FieldApi.ts:1025
Handles the blur event.
void
handleChange(updater): void
handleChange(updater): void
Defined in: packages/form-core/src/FieldApi.ts:1018
Handles the change event.
Updater<TData>
void
insertValue(
index,
value,
opts?): Promise<void>
insertValue(
index,
value,
opts?): Promise<void>
Defined in: packages/form-core/src/FieldApi.ts:686
Inserts a value at the specified index, shifting the subsequent values to the right.
number
TData extends any[] ? TData<TData>[number] : never
UpdateMetaOptions
Promise<void>
mount(): () => void
mount(): () => void
Defined in: packages/form-core/src/FieldApi.ts:567
Mounts the field instance to the form.
Function
void
moveValue(
aIndex,
bIndex,
opts?): void
moveValue(
aIndex,
bIndex,
opts?): void
Defined in: packages/form-core/src/FieldApi.ts:716
Moves the value at the first specified index to the second specified index.
number
number
UpdateMetaOptions
void
pushValue(value, opts?): void
pushValue(value, opts?): void
Defined in: packages/form-core/src/FieldApi.ts:678
Pushes a new value to the field.
TData extends any[] ? TData<TData>[number] : never
UpdateMetaOptions
void
removeValue(index, opts?): Promise<void>
removeValue(index, opts?): Promise<void>
Defined in: packages/form-core/src/FieldApi.ts:704
Removes a value at the specified index.
number
UpdateMetaOptions
Promise<void>
replaceValue(
index,
value,
opts?): Promise<void>
replaceValue(
index,
value,
opts?): Promise<void>
Defined in: packages/form-core/src/FieldApi.ts:695
Replaces a value at the specified index.
number
TData extends any[] ? TData<TData>[number] : never
UpdateMetaOptions
Promise<void>
setErrorMap(errorMap): void
setErrorMap(errorMap): void
Defined in: packages/form-core/src/FieldApi.ts:1045
Updates the field's errorMap
ValidationErrorMap
void
setMeta(updater): void
setMeta(updater): void
Defined in: packages/form-core/src/FieldApi.ts:667
Sets the field metadata.
void
setValue(updater, options?): void
setValue(updater, options?): void
Defined in: packages/form-core/src/FieldApi.ts:651
Sets the field value and run the change validator.
Updater<TData>
UpdateMetaOptions
void
swapValues(
aIndex,
bIndex,
opts?): void
swapValues(
aIndex,
bIndex,
opts?): void
Defined in: packages/form-core/src/FieldApi.ts:710
Swaps the values at the specified indices.
number
number
UpdateMetaOptions
void
update(opts): void
update(opts): void
Defined in: packages/form-core/src/FieldApi.ts:606
Updates the field instance with new options.
FieldApiOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>
void
validate(cause):
| ValidationError[]
| Promise<ValidationError[]>
validate(cause):
| ValidationError[]
| Promise<ValidationError[]>
Defined in: packages/form-core/src/FieldApi.ts:990
Validates the field value.
ValidationCause
| ValidationError[] | Promise<ValidationError[]>
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.