@modular-forms/qwik
Version:
The modular and type-safe form library for Qwik
17 lines (16 loc) • 527 B
JavaScript
import { initializeFieldStore } from './initializeFieldStore';
/**
* Sets the store of a field to the specified state.
*
* @param form The form of the field.
* @param name The name of the field.
* @param state The new state to be set.
*/
export function setFieldState(form, name, state) {
const field = initializeFieldStore(form, name);
field.internal.startValue = state.startValue;
field.value = state.value;
field.error = state.error;
field.touched = state.touched;
field.dirty = state.dirty;
}