@modular-forms/solid
Version:
The modular and type-safe form library for SolidJS
17 lines (16 loc) • 545 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.startValue.set(() => state.startValue);
field.value.set(() => state.value);
field.error.set(state.error);
field.touched.set(state.touched);
field.dirty.set(state.dirty);
}